personal.vue 15 KB

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