member-renew.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. <template>
  2. <view class="container clearfix">
  3. <view class="cm-member-top">
  4. <view class="cm-member-head">
  5. <view class="cm-member-text" v-if="isRequest">
  6. <view class="cm-member-h1">
  7. <text v-if="userVip.vipFlag == 0">采美·超级会员</text>
  8. <text v-if="userVip.vipFlag == 1">已开通采美·超级会员</text>
  9. <text v-if="userVip.vipFlag == -1">采美·超级会员已过期</text>
  10. </view>
  11. <view class="cm-member-p">
  12. <text v-if="userVip.vipFlag == 0">享专属特权</text>
  13. <text v-else>有效期至:{{ userVip.endTime }}</text>
  14. </view>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="cm-member-main">
  19. <view class="title">超级会员套餐</view>
  20. <view class="cm-member-pay">
  21. <view
  22. class="pay-item"
  23. v-for="(pay, index) in payList"
  24. :key="index"
  25. :class="{ current: tabCurrent === index }"
  26. @click="handleCheckedPay(index, pay)"
  27. >
  28. <view class="hot" v-if="index == 0">推荐</view> <view class="text-1">{{ pay.duration }}个月</view>
  29. <view class="text-2"> <text>¥</text>{{ pay.price }}</view>
  30. <view class="text-3" v-if="index == 0 || index == 1">{{ pay.price / pay.duration }}/月</view>
  31. </view>
  32. </view>
  33. <view class="cm-member-button">
  34. <view class="pay-btn pay" @click="hanldWechatPay">立即支付{{ handelPayMsg.price }}元开通</view>
  35. <view class="pay-btn none" @click="hanldeShowBeans">抵扣{{ handelPayMsg.beans }}个采美豆开通</view>
  36. </view>
  37. </view>
  38. <!-- 弹窗 -->
  39. <template>
  40. <view class="cm-model-alert" v-if="isShowBeansModal">
  41. <view class="content">
  42. <view class="title">
  43. <text>购买超级会员</text>
  44. <text class="iconfont icon-iconfontguanbi" @click.stop="handelCanelBeans"></text>
  45. </view>
  46. <view class="text-content">
  47. <view class="text"
  48. >确定使用<text class="text-p">{{ handelPayMsg.beans }}</text
  49. >个采美豆抵扣{{ handelPayMsg.duration }}个月的采美超级会员吗?</view
  50. >
  51. </view>
  52. <view class="text-button">
  53. <view class="btn btn-cancel" @click="handelCanelBeans">取消</view>
  54. <view class="btn btn-confirm" @click="handelConfirmBeans">确定</view>
  55. </view>
  56. </view>
  57. </view>
  58. </template>
  59. </view>
  60. </template>
  61. <script>
  62. import { mapState, mapMutations } from 'vuex'
  63. export default {
  64. components: {},
  65. data() {
  66. return {
  67. StaticUrl: this.$Static,
  68. isRequest: false,
  69. isShowBeansModal: false,
  70. payList: [],
  71. userVip: {},
  72. handelPayMsg: {
  73. beans: 0,
  74. price: 0,
  75. month: '',
  76. packageId: 0
  77. },
  78. payParam: {
  79. userId: 0,
  80. packageId: 1
  81. },
  82. tabCurrent: 0
  83. }
  84. },
  85. onLoad() {},
  86. filters: {
  87. TypeFormat(value) {
  88. switch (value) {
  89. case 0:
  90. return '活动券'
  91. break
  92. case 1:
  93. return '品类券'
  94. break
  95. case 2:
  96. return '用户专享券'
  97. break
  98. case 3:
  99. return '店铺券'
  100. break
  101. case 4:
  102. return '新用户券'
  103. break
  104. }
  105. }
  106. },
  107. computed: {
  108. ...mapState(['hasLogin', 'userInfo', 'identity', 'isActivity'])
  109. },
  110. methods: {
  111. async initGetStotage() {
  112. const userInfo = await this.$api.getStorage()
  113. this.payParam.userId = userInfo.userId ? userInfo.userId : 0
  114. this.userIdentity = userInfo.userIdentity ? userInfo.userIdentity : 0
  115. this.getUserSuperPackage()
  116. this.getUserSuperCenter()
  117. },
  118. getUserSuperPackage() {
  119. //获取会员中心套餐
  120. this.UserService.getUserSuperPackage()
  121. .then(response => {
  122. let data = response.data
  123. data.forEach(el => {
  124. el.beans = el.price * el.proportion
  125. el.packageId = el.id
  126. })
  127. this.payList = data
  128. this.handelPayMsg = data[0]
  129. this.payParam.packageId = data[0].packageId
  130. })
  131. .catch(error => {
  132. console.log('获取会员套餐异常~')
  133. })
  134. },
  135. getUserSuperCenter() {
  136. // 获取会员中心数据
  137. this.UserService.getUserSuperCenter({ userId: this.payParam.userId })
  138. .then(response => {
  139. let data = response.data
  140. this.userVip = data.vip
  141. this.isRequest = true
  142. })
  143. .catch(error => {
  144. this.$util.msg(error.msg, 2000)
  145. })
  146. },
  147. hanldeShowBeans() {
  148. // 显示采美豆抵扣开通超级会员弹窗
  149. this.isShowBeansModal = true
  150. },
  151. handelCanelBeans() {
  152. // 取消采美豆抵扣超级会员
  153. this.isShowBeansModal = false
  154. },
  155. handelConfirmBeans() {
  156. // 确认采美豆抵扣开通超级会员
  157. this.PayService.getUserRegisterSuperBeans(this.payParam)
  158. .then(response => {
  159. this.isShowBeansModal = false
  160. this.$util.msg('续费成功', 2000, true, 'success')
  161. setTimeout(() => {
  162. this.$api.navigateTo('/pages/user/member/member')
  163. }, 2000)
  164. })
  165. .catch(error => {
  166. this.$util.msg(error.msg, 2000)
  167. })
  168. },
  169. hanldWechatPay() {
  170. // 跳转微信只开通超级会员
  171. this.PayService.getUserRegisterSuperPay(this.payParam)
  172. .then(response => {
  173. this.handelPayMsg.vipRecordId = response.data
  174. this.$api.navigateTo(`/pages/user/member/member-pay?data=${JSON.stringify(this.handelPayMsg)}`)
  175. })
  176. .catch(error => {
  177. this.$util.msg(error.msg, 2000)
  178. })
  179. },
  180. handleCheckedPay(index, pay) {
  181. // 选择会员
  182. this.tabCurrent = index
  183. this.payParam.packageId = pay.packageId
  184. this.handelPayMsg = pay
  185. }
  186. },
  187. onShow() {
  188. this.initGetStotage()
  189. }
  190. }
  191. </script>
  192. <style lang="scss">
  193. .container {
  194. width: 100%;
  195. height: auto;
  196. }
  197. .cm-member-top {
  198. width: 100%;
  199. height: 242rpx;
  200. box-sizing: border-box;
  201. padding: 0 24rpx;
  202. background: url(https://static.caimei365.com/app/img/icon/icon-member-bg01@2x.png) no-repeat;
  203. background-size: cover;
  204. position: relative;
  205. .cm-member-head {
  206. width: 702rpx;
  207. height: 132rpx;
  208. box-sizing: border-box;
  209. padding: 30rpx 32rpx 0 109rpx;
  210. background: url(https://static.caimei365.com/app/img/icon/icon-member-bg02@2x.png) no-repeat;
  211. background-size: cover;
  212. position: absolute;
  213. bottom: 0;
  214. left: 24rpx;
  215. border-radius: 16rpx 16rpx 0 0;
  216. .cm-member-text {
  217. float: left;
  218. .cm-member-h1 {
  219. line-height: 42rpx;
  220. font-size: $font-size-30;
  221. color: #55331d;
  222. text-align: left;
  223. margin-bottom: 12rpx;
  224. font-weight: bold;
  225. }
  226. .cm-member-p {
  227. line-height: 30rpx;
  228. font-size: $font-size-22;
  229. color: #55331d;
  230. text-align: left;
  231. }
  232. }
  233. }
  234. }
  235. .cm-member-main {
  236. width: 100%;
  237. box-sizing: border-box;
  238. padding: 40rpx 24rpx;
  239. background-color: #ffffff;
  240. margin-bottom: 20rpx;
  241. .title {
  242. font-size: $font-size-32;
  243. line-height: 45rpx;
  244. text-align: left;
  245. color: #55331d;
  246. font-weight: bold;
  247. .small {
  248. font-size: $font-size-24;
  249. color: #e4aa43;
  250. font-weight: normal;
  251. margin-left: 15rpx;
  252. }
  253. }
  254. .cm-member-pay {
  255. width: 100%;
  256. height: 236rpx;
  257. margin: 40rpx 0;
  258. .pay-item {
  259. width: 218rpx;
  260. height: 100%;
  261. float: left;
  262. margin-right: 24rpx;
  263. border: 1px solid #f0f0f0;
  264. border-radius: 16rpx;
  265. box-sizing: border-box;
  266. text-align: center;
  267. padding: 40rpx 0;
  268. position: relative;
  269. .hot {
  270. width: 80rpx;
  271. height: 36rpx;
  272. text-align: center;
  273. line-height: 36rpx;
  274. font-size: $font-size-24;
  275. color: #ffffff;
  276. background-color: #ff2a2a;
  277. border-radius: 0 8rpx 8rpx 8rpx;
  278. position: absolute;
  279. left: 0;
  280. top: -10rpx;
  281. }
  282. &.current {
  283. background-color: #fdf8ee;
  284. border: 1px solid #f0cc8c;
  285. }
  286. &:last-child {
  287. margin-right: 0;
  288. }
  289. .text-1 {
  290. line-height: 40rpx;
  291. font-size: $font-size-28;
  292. margin-bottom: 10rpx;
  293. color: #55331d;
  294. }
  295. .text-2 {
  296. line-height: 59rpx;
  297. font-size: $font-size-40;
  298. margin-bottom: 10rpx;
  299. color: #ff2a2a;
  300. font-weight: bold;
  301. text {
  302. font-size: $font-size-26;
  303. }
  304. }
  305. .text-3 {
  306. line-height: 33rpx;
  307. font-size: $font-size-24;
  308. color: #666666;
  309. }
  310. }
  311. }
  312. .cm-member-button {
  313. width: 100%;
  314. box-sizing: border-box;
  315. padding: 0 51rpx;
  316. .pay-btn {
  317. width: 100%;
  318. height: 90rpx;
  319. line-height: 90rpx;
  320. border-radius: 50rpx;
  321. text-align: center;
  322. font-size: $font-size-30;
  323. color: #55331d;
  324. box-sizing: border-box;
  325. margin-bottom: $font-size-24;
  326. &.pay {
  327. background: linear-gradient(90deg, #fee9ba 0%, #f0cb72 100%);
  328. font-weight: bold;
  329. }
  330. &.none {
  331. border: 1px solid #f0cb72;
  332. margin-bottom: 0;
  333. }
  334. }
  335. }
  336. }
  337. .cm-model-alert {
  338. width: 100%;
  339. height: 100%;
  340. background: rgba(0, 0, 0, 0.5);
  341. position: fixed;
  342. top: 0;
  343. left: 0;
  344. z-index: 8888;
  345. transition: all 0.4s;
  346. .content {
  347. width: 580rpx;
  348. height: 390rpx;
  349. position: absolute;
  350. background: $bg-color;
  351. left: 0;
  352. right: 0;
  353. bottom: 0;
  354. top: 0;
  355. margin: auto;
  356. padding: 20rpx 32rpx;
  357. border-radius: 12rpx;
  358. .title {
  359. width: 100%;
  360. height: 68rpx;
  361. line-height: 68rpx;
  362. font-size: $font-size-28;
  363. color: $text-color;
  364. text-align: center;
  365. position: relative;
  366. .icon-iconfontguanbi {
  367. width: 68rpx;
  368. height: 68rpx;
  369. text-align: center;
  370. line-height: 68rpx;
  371. position: absolute;
  372. right: 0;
  373. top: 0;
  374. font-size: $font-size-36;
  375. color: #999999;
  376. }
  377. }
  378. .text-content {
  379. width: 100%;
  380. height: auto;
  381. margin-top: 20px;
  382. .text {
  383. padding: 20rpx 0 0 0;
  384. line-height: 44rpx;
  385. font-size: $font-size-26;
  386. color: #666666;
  387. text-align: justify;
  388. .text-p {
  389. color: #e15616;
  390. }
  391. }
  392. }
  393. .text-button {
  394. width: 100%;
  395. height: 72rpx;
  396. display: flex;
  397. box-sizing: border-box;
  398. padding: 0 50rpx;
  399. margin-top: 30px;
  400. .btn {
  401. width: 200rpx;
  402. height: 72rpx;
  403. line-height: 72rpx;
  404. color: #fff;
  405. display: flex;
  406. align-items: center;
  407. justify-content: center;
  408. font-size: $font-size-26;
  409. border-radius: 44rpx;
  410. box-sizing: border-box;
  411. &.btn-confirm {
  412. background: $btn-confirm;
  413. margin-left: 78rpx;
  414. }
  415. &.btn-cancel {
  416. border: 1px solid #b2b2b2;
  417. color: #333333;
  418. }
  419. }
  420. }
  421. }
  422. }
  423. </style>