member-renew.vue 9.6 KB

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