member-renew.vue 9.4 KB

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