personal.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  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 == 11">有效期至 {{ userinfo['validity_time_formatted'] }}</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 padding-top-xl ">
  75. <view class="margin-top-xl flex justify-center">
  76. <text class="title" >水母会员次卡体验券1张</text>
  77. </view>
  78. <view class="flex justify-center margin-top">
  79. <text class="text-xs">{{userinfo.certainTime}}&nbsp;当天领取有效</text>
  80. </view>
  81. <div class="flex justify-center margin-top" >
  82. <view class="flex justify-center quan_container_lil">
  83. <div style="display: flex;align-items: baseline">
  84. <text class="experience time">{{ gift_time }}</text>
  85. <text class="time_text margin-left-xs">次</text>
  86. </div>
  87. </view>
  88. </div>
  89. </div>
  90. <view class="flex justify-center margin-top-xl">
  91. <button class="cu-btn get_btn text-white" @click="get_ticket">领取</button>
  92. </view>
  93. </van-popup> -->
  94. <!-- 外发领券弹窗-->
  95. <van-popup
  96. :show="is_outShow"
  97. :close-on-click-overlay="false"
  98. custom-class="pop"
  99. overlay
  100. z-index="99"
  101. >
  102. <div class="quan_container padding-tb-xl">
  103. <view class="margin-top-xl flex justify-center">
  104. <text class="title">{{outCouponData.name}}</text>
  105. </view>
  106. <view class="flex justify-center margin-top">
  107. <text class="text-xs" v-if="outCouponData.validity_time.type==1">{{outCouponData.validity_time.time_format}}&nbsp;之前领取有效</text>
  108. <text class="text-xs" v-else>{{outCouponData.validity_time.start_time_format}}&nbsp;至&nbsp;{{outCouponData.validity_time.end_time_format}}&nbsp;之前领取有效</text>
  109. </view>
  110. <!-- 核销 -->
  111. <view class="flex justify-center margin-top" v-if="outCouponData.type==1">
  112. <div class="flex justify-center quan_container_lil">
  113. <div style="display: flex;align-items: baseline">
  114. <text class="hexiao time margin-right-xs">{{ outCouponData.discount.time }}</text>
  115. <text class="time_text" v-if="outCouponData.discount.type==0">分钟</text>
  116. <text class="time_text" v-else>次</text>
  117. </div>
  118. </div>
  119. </view>
  120. <!-- 满减 -->
  121. <view class="flex justify-center margin-top" v-if="outCouponData.type==2">
  122. <div class="flex justify-center quan_container_lil">
  123. <div style="display: flex;align-items: baseline">
  124. <text class="time_text">满</text>
  125. <text class="manjian time margin-lr-xs">{{ outCouponData.discount.full }}</text>
  126. <text class="time_text">减</text>
  127. <text class="manjian time margin-left-xs">{{ outCouponData.discount.reduce }}</text>
  128. </div>
  129. </div>
  130. </view>
  131. <!-- 折扣 -->
  132. <view class="flex justify-center margin-top" v-if="outCouponData.type==3">
  133. <div class="flex justify-center quan_container_lil">
  134. <div style="display: flex;align-items: baseline">
  135. <text class="time_text">打</text>
  136. <text class="discount time margin-lr-sm">{{ outCouponData.discount.discount*10 }}</text>
  137. <text class="time_text">折</text>
  138. </div>
  139. </div>
  140. </view>
  141. <!-- 随机 -->
  142. <view class="flex justify-center margin-top" v-if="outCouponData.type==4">
  143. <div class="flex justify-center quan_container_lil">
  144. <div style="display: flex;align-items: baseline">
  145. <text class="time_text">随机</text>
  146. <text class="random time margin-lr-xs">{{ outCouponData.discount.start }}</text>
  147. <text class="time_text">至</text>
  148. <text class="random time margin-lr-xs">{{ outCouponData.discount.end }}</text>
  149. <text class="time_text">元</text>
  150. </div>
  151. </div>
  152. </view>
  153. </div>
  154. <view class="flex justify-center margin-top-xl">
  155. <button class="cu-btn get_btn text-white" @click="get_coupon">领取</button>
  156. </view>
  157. </van-popup>
  158. <!-- 窗口弹出-->
  159. <van-popup :show="pop_show" @close="close_pop" round>
  160. <div class="err_container flex flex-direction align-center justify-around">
  161. <view>
  162. <text class="title">
  163. 您当前剩余时间不足
  164. </text>
  165. </view>
  166. <view>
  167. <text class="sub-title">
  168. 请充值后进行游戏
  169. </text>
  170. </view>
  171. <img src="https://img.shuimuai.com/web/sign_notimeJfish.png" class="err_img" alt="">
  172. <button class="cu-btn lg bg-primary text-white" @click="to_recharge">立即充值</button>
  173. </div>
  174. </van-popup>
  175. <van-toast id="van-toast"/>
  176. </div>
  177. </template>
  178. <script>
  179. import { userUpdateLoginTime } from "../../requests/user";
  180. import {
  181. couponReceiveFirst,
  182. couponReceiveFirstID,
  183. outputCoupon,
  184. couponReceive,
  185. outCardCoupon,
  186. } from "../../requests/coupons";
  187. import Toast from "../../../static/vant/toast/toast";
  188. import { reload_userinfo } from "../../utils/user";
  189. import { timestampTwoNum } from "../../utils/index";
  190. import user_store from "@/store/index";
  191. var $this;
  192. export default {
  193. name: "personal",
  194. data() {
  195. return {
  196. userinfo: {
  197. //判断是否第一次进入小程序 1为是第一次 0为非第一次
  198. },
  199. first: false,
  200. pop_show: false,
  201. receive: 0,
  202. invite_code: false,
  203. // twenty: false,
  204. // 外发
  205. output: false,
  206. is_outShow: false,
  207. outCouponData: {
  208. type: Number,
  209. validity_time: {
  210. type: Number,
  211. },
  212. discount: {
  213. type: Number,
  214. },
  215. },
  216. // gift_time: Number
  217. };
  218. },
  219. methods: {
  220. //会员日注册领取体验卡
  221. // get_ticket() {
  222. // if ($this.receive == 0) {
  223. // $this.receive += 1;
  224. // console.log($this.receive);
  225. // $this.first = false;
  226. // let params
  227. // couponReceiveFirstID().then((res)=>{
  228. // let resData = res.data.data
  229. // params={
  230. // ID: resData.coupon_category_id,
  231. // start_time: resData.validity_time.start_time,
  232. // end_time: resData.validity_time.end_time,
  233. // }
  234. // couponReceiveFirst(params).then((res) => {
  235. // let $res = res.data;
  236. // if ($res.code == 0) {
  237. // $this.first = false;
  238. // userUpdateLoginTime().then((res) => {
  239. // let $res = res.data;
  240. // $this.userinfo["login_time"] = $res.data;
  241. // $this.$store = user_store.setters.set_userinfo($this.userinfo);
  242. // wx.setStorageSync("is_first", false);
  243. // reload_userinfo($this);
  244. // });
  245. // Toast.success($res.errmsg);
  246. // } else {
  247. // Toast.fail($res.errmsg);
  248. // }
  249. // });
  250. // })
  251. // }
  252. // },
  253. //领取外发卡券
  254. get_coupon() {
  255. wx.setStorageSync("is_out", false);
  256. couponReceive($this.outCouponData)
  257. .then((res) => {
  258. let $res = res.data;
  259. if ($res.code == 0) {
  260. Toast.success({
  261. message: $res.errmsg,
  262. duration: 800,
  263. onClose() {
  264. reload_userinfo($this);
  265. },
  266. });
  267. $this.is_outShow = false;
  268. } else {
  269. Toast.fail({
  270. message: $res.errmsg,
  271. duration: 800,
  272. });
  273. $this.is_outShow = false;
  274. }
  275. })
  276. .catch((err) => {
  277. console.log("错误", err);
  278. });
  279. },
  280. //修改第一次登录状态
  281. close_pop() {
  282. this.pop_show = false;
  283. },
  284. //跳转充值中心
  285. to_recharge() {
  286. mpvue.navigateTo({
  287. url: "/pages/user_center/recharge/main",
  288. });
  289. },
  290. //跳转用户中心
  291. to_user_center() {
  292. mpvue.navigateTo({
  293. url: "/pages/user_center/main",
  294. });
  295. },
  296. to_coupons() {
  297. mpvue.navigateTo({
  298. url: "/pages/coupons/main",
  299. });
  300. },
  301. change_login_status() {
  302. $this.$emit("change_login_status");
  303. },
  304. // 外发通用数据处理
  305. handle_coupon_data(res) {
  306. if (res.data.code == 0) {
  307. let $newData = res.data.data;
  308. $newData.validity_time["start_time_format"] = timestampTwoNum(
  309. $newData.validity_time["start_time"]
  310. );
  311. $newData.validity_time["end_time_format"] = timestampTwoNum(
  312. $newData.validity_time["end_time"]
  313. );
  314. $newData.validity_time["time_format"] = timestampTwoNum(
  315. $newData.validity_time["time"]
  316. );
  317. $this.outCouponData = $newData;
  318. console.log("外发数据:", $this.outCouponData);
  319. $this.is_outShow = true;
  320. } else {
  321. wx.setStorageSync("is_out", false);
  322. $this.output = false;
  323. }
  324. },
  325. // 获取不同外发券
  326. check_output_coupon() {
  327. //外发
  328. $this.output = wx.getStorageSync("is_out");
  329. reload_userinfo($this);
  330. //获取外发数据
  331. if ($this.output == true) {
  332. // 判断外发哪种券
  333. if (wx.getStorageSync("is_other") == false) {
  334. outputCoupon().then((res) => {
  335. handle_coupon_data(res)
  336. });
  337. } else {
  338. outCardCoupon().then((res) => {
  339. handle_coupon_data(res)
  340. });
  341. }
  342. }
  343. },
  344. },
  345. mounted() {
  346. $this.first = wx.getStorageSync("is_first");
  347. $this.invite_code = wx.getStorageSync("code");
  348. $this.check_output_coupon();
  349. //判断是否每月20号
  350. // let day = new Date().getDate();
  351. // if (day == 20) {
  352. // wx.setStorageSync("is_twenty", true);
  353. // couponReceiveFirstID().then((res)=>{
  354. // console.log('体验次卡',res.data.data.discount.time)
  355. // $this.gift_time = res.data.data.discount.time
  356. // })
  357. // } else {
  358. // wx.setStorageSync("is_twenty", false);
  359. // }
  360. // $this.twenty = wx.getStorageSync("is_twenty");
  361. // console.log("可以领注册体验券吗", $this.first & $this.twenty);
  362. },
  363. onShow() {
  364. $this.check_output_coupon();
  365. },
  366. created() {
  367. $this = this;
  368. },
  369. onPullDownRefresh() {
  370. reload_userinfo($this);
  371. },
  372. };
  373. </script>
  374. <style scoped>
  375. .userinfoYellow {
  376. background-image: url("https://img.shuimuai.com/huiyuankadiban.png");
  377. background-position: center;
  378. background-size: 100% 100%;
  379. width: 99%;
  380. height: 173px;
  381. margin: 0px auto;
  382. }
  383. .userinfoGrey {
  384. background-image: url("https://img.shuimuai.com/pic_grey.png");
  385. background-position: center;
  386. background-size: 100% 100%;
  387. width: 99%;
  388. height: 173px;
  389. margin: 0px auto;
  390. }
  391. #personal {
  392. width: 100%;
  393. position: relative;
  394. top: -95px;
  395. z-index: 3;
  396. }
  397. .level_btn_yellow {
  398. background-color: #e3a000;
  399. }
  400. .level_btn_grey {
  401. background-color: #909090;
  402. }
  403. .jifen {
  404. position: absolute;
  405. top: 73px;
  406. }
  407. .font-sm {
  408. font-size: 10px;
  409. }
  410. .quan_container {
  411. background-image: url("https://img.shuimuai.com/pic_getCoupon2.png");
  412. background-position: center;
  413. background-size: 100% 100%;
  414. width: 270px;
  415. height: 235px;
  416. padding-left: 5px;
  417. }
  418. .quan_container_lil {
  419. background-image: url("https://img.shuimuai.com/pic_getCouponlil.png");
  420. background-position: center;
  421. background-size: 100% 100%;
  422. width: 185px;
  423. height: 56px;
  424. display: flex;
  425. align-items: center;
  426. }
  427. /*标题*/
  428. .quan_container .title {
  429. font-size: 15px;
  430. font-weight: bold;
  431. color: #222222;
  432. font-family: Microsoft YaHei;
  433. margin: 6px 0 -5px 0;
  434. }
  435. /*副标题*/
  436. .quan_container .sub-title {
  437. font-size: 10px;
  438. font-weight: 400;
  439. font-family: Microsoft YaHei;
  440. color: #030000;
  441. }
  442. /*分钟数*/
  443. .quan_container .time {
  444. font-weight: bold;
  445. color: #6858c4;
  446. }
  447. .hexiao,
  448. .discount,
  449. .experience {
  450. font-size: 36px;
  451. }
  452. .random {
  453. font-size: 19px;
  454. }
  455. .manjian {
  456. font-size: 24px;
  457. }
  458. /*分钟二字*/
  459. .quan_container .time_text {
  460. font-size: 12px;
  461. font-weight: 400;
  462. color: #6858c4;
  463. }
  464. /* 领取按钮 */
  465. .get_btn {
  466. width: 119px;
  467. height: 31px;
  468. background: #6858c4;
  469. border-radius: 15px;
  470. }
  471. /*弹窗模块*/
  472. .err_container {
  473. width: 260px;
  474. height: 300px;
  475. border-radius: 5px;
  476. }
  477. /*标题*/
  478. .err_container .title {
  479. font-size: 20px;
  480. font-weight: bold;
  481. color: #4c4c4c;
  482. line-height: 24px;
  483. }
  484. /*子标题*/
  485. .err_container .sub-title {
  486. font-size: 12px;
  487. font-family: Microsoft YaHei;
  488. font-weight: 400;
  489. color: #4b4b4b;
  490. line-height: 24px;
  491. }
  492. .err_img {
  493. width: 73px;
  494. height: 83px;
  495. }
  496. </style>
  497. <style>
  498. .pop {
  499. background-color: rgba(255, 255, 255, 0) !important;
  500. }
  501. </style>