personal.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. <template>
  2. <div id="personal">
  3. <!-- 用户信息-->
  4. <div :class="{userinfoYellow:userinfo.isActive, userinfoGrey:userinfo.isntActive}" >
  5. <van-row class="padding">
  6. <van-col span="3" offset="2">
  7. <view class="cu-avatar radius lg" :style="'background-image:url('+userinfo.portrait+');'"></view>
  8. </van-col>
  9. <van-col span="12" offset="1">
  10. <div class="flex flex-direction align-start justify-start">
  11. <div>
  12. <text class="text-black text-bold">{{ userinfo.user_name }}</text>
  13. </div>
  14. <div class="flex justify-between align-center">
  15. <button class="cu-btn sm round" :class="{level_btn_yellow:userinfo.isActive, level_btn_grey:userinfo.isntActive}">
  16. {{ userinfo.level_name }}
  17. </button>
  18. <view class="text-xs padding-left" v-if="userinfo.level != 1">有效期至 {{ userinfo['validity_time'] }}</view>
  19. </div>
  20. </div>
  21. </van-col>
  22. <van-col span="5">
  23. <view class="text" @click="to_user_center">
  24. <text class="cuIcon-people"></text>
  25. <text class="under_line">会员中心</text>
  26. </view>
  27. </van-col>
  28. </van-row>
  29. <van-row class="padding">
  30. <view style="opacity: 1;">
  31. <van-col span="4" class="lg" offset="2">
  32. <text class="cuIcon-selection"></text>
  33. 卡号:
  34. </van-col>
  35. <van-col span="8">
  36. <text class="text-white text-bold text-lg">{{ invite_code }}</text>
  37. </van-col>
  38. </view>
  39. </van-row>
  40. <van-row>
  41. <van-col span="6" offset="1">
  42. <div class="flex flex-direction align-center">
  43. <text class="text-xxl">{{ userinfo.play_time }}</text>
  44. <text class="font-sm">可用时长(分钟)</text>
  45. </div>
  46. </van-col>
  47. <van-col span="7" offset="2" @click="to_coupons">
  48. <div class="flex flex-direction align-center">
  49. <text class="text-xxl">{{ userinfo.coupon }}</text>
  50. <text class="font-sm">已领券数量</text>
  51. </div>
  52. </van-col>
  53. <van-col span="6" offset="2">
  54. <div class="flex flex-direction align-center">
  55. <text class="text-xxl">{{ userinfo.experience }}</text>
  56. <text class="font-sm">次卡</text>
  57. </div>
  58. </van-col>
  59. </van-row>
  60. </div>
  61. <view class="text-center font-sm" v-if="userinfo.level >= 3 && userinfo.level <= 7">
  62. <text class="text-gray">今日专注力免费训练时长还有:
  63. <text class="text-yellow">{{ userinfo.free_time }}</text>
  64. </text>
  65. </view>
  66. <!-- 领券弹窗-->
  67. <van-popup
  68. :show="twenty&first"
  69. :close-on-click-overlay="false"
  70. custom-class="pop"
  71. overlay
  72. z-index="99"
  73. >
  74. <div class="quan_container">
  75. <van-row gutter="10">
  76. <van-col span="14" offset="1">
  77. <div class="padding-top-sm margin-bottom-sm">
  78. <text class="title">
  79. 水母会员次卡体验券1张
  80. </text>
  81. <text class="text-xs ">
  82. {{userinfo.certainTime}}&nbsp;当天领取有效
  83. </text>
  84. </div>
  85. <view class="padding-tb">
  86. <text class="time">
  87. 10
  88. </text>
  89. <text class="time_text">
  90. 分钟
  91. </text>
  92. </view>
  93. </van-col>
  94. <van-col span="5" offset="4" class="" @click="get_ticket">
  95. <view class="get_ticket_text">领取</view>
  96. </van-col>
  97. </van-row>
  98. </div>
  99. </van-popup>
  100. <!-- 窗口弹出-->
  101. <van-popup :show="pop_show" @close="close_pop" round>
  102. <div class="err_container flex flex-direction align-center justify-around">
  103. <view>
  104. <text class="title">
  105. 您当前剩余时间不足
  106. </text>
  107. </view>
  108. <view>
  109. <text class="sub-title">
  110. 请充值后进行游戏
  111. </text>
  112. </view>
  113. <img src="https://img.shuimuai.com/web/sign_notimeJfish.png" class="err_img" alt="">
  114. <button class="cu-btn lg bg-primary text-white" @click="to_recharge">立即充值</button>
  115. </div>
  116. </van-popup>
  117. <van-toast id="van-toast"/>
  118. </div>
  119. </template>
  120. <script>
  121. import { userUpdateLoginTime } from "../../requests/user";
  122. import { couponReceiveFirst } from "../../requests/coupons";
  123. import Toast from "../../../static/vant/toast/toast";
  124. import { reload_userinfo } from "../../utils/user";
  125. import user_store from "@/store/index";
  126. var $this;
  127. export default {
  128. name: "personal",
  129. data() {
  130. return {
  131. userinfo: {
  132. //判断是否第一次进入小程序 1为是第一次 0为非第一次
  133. },
  134. first: false,
  135. pop_show: false,
  136. receive: 0,
  137. invite_code: false,
  138. twenty: false,
  139. };
  140. },
  141. methods: {
  142. get_ticket() {
  143. if ($this.receive == 0) {
  144. $this.receive += 1;
  145. console.log($this.receive);
  146. $this.first = false;
  147. couponReceiveFirst().then((res) => {
  148. let $res = res.data;
  149. if ($res.code == 0) {
  150. $this.first = false;
  151. userUpdateLoginTime().then((res) => {
  152. let $res = res.data;
  153. $this.userinfo["login_time"] = $res.data;
  154. $this.$store = user_store.setters.set_userinfo($this.userinfo);
  155. wx.setStorageSync("is_first", false);
  156. reload_userinfo($this);
  157. });
  158. Toast.success($res.errmsg);
  159. } else {
  160. Toast.fail($res.errmsg);
  161. }
  162. });
  163. }
  164. },
  165. //修改第一次登录状态
  166. close_pop() {
  167. this.pop_show = false;
  168. },
  169. //跳转充值中心
  170. to_recharge() {
  171. mpvue.navigateTo({
  172. url: "/pages/user_center/recharge/main",
  173. });
  174. },
  175. //跳转用户中心
  176. to_user_center() {
  177. mpvue.navigateTo({
  178. url: "/pages/user_center/main",
  179. });
  180. },
  181. to_coupons() {
  182. mpvue.navigateTo({
  183. url: "/pages/coupons/main",
  184. });
  185. },
  186. change_login_status() {
  187. $this.$emit("change_login_status");
  188. },
  189. },
  190. mounted() {
  191. $this.first = wx.getStorageSync("is_first");
  192. $this.invite_code = wx.getStorageSync("code");
  193. reload_userinfo($this);
  194. //判断是否每月20号
  195. let day = new Date().getDate();
  196. if (day == 20) {
  197. wx.setStorageSync("is_twenty", true);
  198. } else {
  199. wx.setStorageSync("is_twenty", false);
  200. }
  201. $this.twenty = wx.getStorageSync("is_twenty");
  202. console.log("状态", $this.first & $this.twenty);
  203. },
  204. onShow() {
  205. reload_userinfo($this);
  206. },
  207. created() {
  208. $this = this;
  209. },
  210. onPullDownRefresh() {
  211. reload_userinfo($this);
  212. },
  213. };
  214. </script>
  215. <style scoped>
  216. .userinfoYellow {
  217. background-image: url("https://img.shuimuai.com/huiyuankadiban.png");
  218. background-position: center;
  219. background-size: 100% 100%;
  220. width: 99%;
  221. height: 173px;
  222. margin: 0px auto;
  223. }
  224. .userinfoGrey {
  225. background-image: url("https://img.shuimuai.com/pic_grey.png");
  226. /* background-image: url("https://img.shuimuai.com/huiyuankadiban.png"); */
  227. background-position: center;
  228. background-size: 100% 100%;
  229. width: 99%;
  230. height: 173px;
  231. margin: 0px auto;
  232. }
  233. #personal {
  234. width: 100%;
  235. position: relative;
  236. top: -95px;
  237. z-index: 3;
  238. }
  239. .level_btn_yellow {
  240. background-color: #e3a000;
  241. }
  242. .level_btn_grey {
  243. background-color: #909090;
  244. }
  245. .jifen {
  246. position: absolute;
  247. top: 73px;
  248. }
  249. .font-sm {
  250. font-size: 10px;
  251. }
  252. .quan_container {
  253. background-image: url("https://img.shuimuai.com/web/index_item_quan.png");
  254. background-position: center;
  255. background-size: 100% 100%;
  256. width: 340px;
  257. height: 115px;
  258. }
  259. /*标题*/
  260. .quan_container .title {
  261. font-size: 15px;
  262. font-weight: 400;
  263. color: #030000;
  264. line-height: 24px;
  265. }
  266. /*子标题*/
  267. .quan_container .sub-title {
  268. font-size: 10px;
  269. font-weight: 400;
  270. color: #030000;
  271. line-height: 24px;
  272. }
  273. /*分钟数*/
  274. .quan_container .time {
  275. font-size: 36px;
  276. font-weight: 400;
  277. color: #030000;
  278. line-height: 24px;
  279. }
  280. /*分钟二字*/
  281. .quan_container .time_text {
  282. font-size: 12px;
  283. font-weight: 400;
  284. color: #030000;
  285. line-height: 24px;
  286. margin-left: -5px;
  287. }
  288. /*领取二字*/
  289. .quan_container .get_ticket_text {
  290. font-size: 18px;
  291. font-weight: 400;
  292. color: #ffffff;
  293. line-height: 24px;
  294. margin: 45px 0px;
  295. }
  296. /*弹窗模块*/
  297. .err_container {
  298. width: 260px;
  299. height: 300px;
  300. border-radius: 5px;
  301. }
  302. /*标题*/
  303. .err_container .title {
  304. font-size: 20px;
  305. font-weight: bold;
  306. color: #4c4c4c;
  307. line-height: 24px;
  308. }
  309. /*子标题*/
  310. .err_container .sub-title {
  311. font-size: 12px;
  312. font-family: Microsoft YaHei;
  313. font-weight: 400;
  314. color: #4b4b4b;
  315. line-height: 24px;
  316. }
  317. .err_img {
  318. width: 73px;
  319. height: 83px;
  320. }
  321. </style>
  322. <style>
  323. .pop {
  324. background-color: rgba(255, 255, 255, 0) !important;
  325. }
  326. </style>