member-renew.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  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. if (process.env.NODE_ENV != 'development') {
  151. // 友盟埋点收集续费购买超级会员采美豆抵扣会员
  152. this.$uma.trackEvent('Um_Event_userClubRenewMemberBeansConfirm', {
  153. Um_Key_Month: `${this.handelPayMsg.duration}个月`,
  154. Um_Key_SourcePage: '续费购买超级会员'
  155. })
  156. }
  157. this.isShowBeansModal = true
  158. },
  159. handelCanelBeans() {
  160. // 取消采美豆抵扣超级会员
  161. if (process.env.NODE_ENV != 'development') {
  162. // 友盟埋点收集取消采抵扣会员
  163. this.$uma.trackEvent('Um_Event_userClubRenewMemberBeansCancel', {
  164. Um_Key_Month: `${this.handelPayMsg.duration}个月`,
  165. Um_Key_SourcePage: '会员中心'
  166. })
  167. }
  168. this.isShowBeansModal = false
  169. },
  170. handelConfirmBeans() {
  171. // 确认采美豆抵扣开通超级会员
  172. if (process.env.NODE_ENV != 'development') {
  173. // 友盟埋点收集确定采抵扣会员
  174. this.$uma.trackEvent('Um_Event_userClubRenewMemberBeansConfirms', {
  175. Um_Key_Month: `${this.handelPayMsg.duration}个月`,
  176. Um_Key_SourcePage: '会员中心'
  177. })
  178. }
  179. this.PayService.getUserRegisterSuperBeans(this.payParam)
  180. .then(response => {
  181. this.isShowBeansModal = false
  182. this.$util.msg('续费成功', 2000, true, 'success')
  183. setTimeout(() => {
  184. uni.navigateBack({ delta: 1 })
  185. }, 2000)
  186. })
  187. .catch(error => {
  188. this.$util.msg(error.msg, 2000)
  189. })
  190. },
  191. hanldWechatPay() {
  192. // 跳转微信只开通超级会员
  193. if (process.env.NODE_ENV != 'development') {
  194. // 友盟埋点收集线上续费购买超级会员线上支付
  195. this.$uma.trackEvent('Um_Event_userClubRenewMemberConfirm', {
  196. Um_Key_Month: `${this.handelPayMsg.duration}个月`,
  197. Um_Key_SourcePage: '续费购买超级会员'
  198. })
  199. }
  200. this.PayService.getUserRegisterSuperPay(this.payParam)
  201. .then(response => {
  202. this.handelPayMsg.vipRecordId = response.data
  203. this.$api.navigateTo(`/pages/user/member/member-pay?data=${JSON.stringify(this.handelPayMsg)}`)
  204. })
  205. .catch(error => {
  206. this.$util.msg(error.msg, 2000)
  207. })
  208. },
  209. handleCheckedPay(index, pay) {
  210. // 选择会员
  211. this.tabCurrent = index
  212. this.payParam.packageId = pay.packageId
  213. this.handelPayMsg = pay
  214. }
  215. },
  216. onShow() {
  217. this.initGetStotage()
  218. }
  219. }
  220. </script>
  221. <style lang="scss">
  222. .container {
  223. width: 100%;
  224. height: auto;
  225. }
  226. .cm-member-top {
  227. width: 100%;
  228. height: 242rpx;
  229. box-sizing: border-box;
  230. padding: 0 24rpx;
  231. background: url(https://static.caimei365.com/app/img/icon/icon-member-bg01@2x.png) no-repeat;
  232. background-size: cover;
  233. position: relative;
  234. .cm-member-head {
  235. width: 702rpx;
  236. height: 132rpx;
  237. box-sizing: border-box;
  238. padding: 30rpx 32rpx 0 109rpx;
  239. background: url(https://static.caimei365.com/app/img/icon/icon-member-bg02@2x.png) no-repeat;
  240. background-size: cover;
  241. position: absolute;
  242. bottom: 0;
  243. left: 24rpx;
  244. border-radius: 16rpx 16rpx 0 0;
  245. .cm-member-text {
  246. float: left;
  247. .cm-member-h1 {
  248. line-height: 42rpx;
  249. font-size: $font-size-30;
  250. color: #55331d;
  251. text-align: left;
  252. margin-bottom: 12rpx;
  253. font-weight: bold;
  254. }
  255. .cm-member-p {
  256. line-height: 30rpx;
  257. font-size: $font-size-22;
  258. color: #55331d;
  259. text-align: left;
  260. }
  261. }
  262. }
  263. }
  264. .cm-member-main {
  265. width: 100%;
  266. box-sizing: border-box;
  267. padding: 40rpx 24rpx;
  268. background-color: #ffffff;
  269. margin-bottom: 20rpx;
  270. .title {
  271. font-size: $font-size-32;
  272. line-height: 45rpx;
  273. text-align: left;
  274. color: #55331d;
  275. font-weight: bold;
  276. .small {
  277. font-size: $font-size-24;
  278. color: #e4aa43;
  279. font-weight: normal;
  280. margin-left: 15rpx;
  281. }
  282. }
  283. .cm-member-pay {
  284. width: 100%;
  285. height: 236rpx;
  286. margin: 40rpx 0;
  287. .pay-item {
  288. width: 218rpx;
  289. height: 100%;
  290. float: left;
  291. margin-right: 24rpx;
  292. border: 1px solid #f0f0f0;
  293. border-radius: 16rpx;
  294. box-sizing: border-box;
  295. text-align: center;
  296. padding: 40rpx 0;
  297. position: relative;
  298. .hot {
  299. width: 80rpx;
  300. height: 36rpx;
  301. text-align: center;
  302. line-height: 36rpx;
  303. font-size: $font-size-24;
  304. color: #ffffff;
  305. background-color: #ff2a2a;
  306. border-radius: 0 8rpx 8rpx 8rpx;
  307. position: absolute;
  308. left: 0;
  309. top: -10rpx;
  310. }
  311. &.current {
  312. background-color: #fdf8ee;
  313. border: 1px solid #f0cc8c;
  314. }
  315. &:last-child {
  316. margin-right: 0;
  317. }
  318. .text-1 {
  319. line-height: 40rpx;
  320. font-size: $font-size-28;
  321. margin-bottom: 10rpx;
  322. color: #55331d;
  323. }
  324. .text-2 {
  325. line-height: 59rpx;
  326. font-size: $font-size-40;
  327. margin-bottom: 10rpx;
  328. color: #ff2a2a;
  329. font-weight: bold;
  330. text {
  331. font-size: $font-size-26;
  332. }
  333. }
  334. .text-3 {
  335. line-height: 33rpx;
  336. font-size: $font-size-24;
  337. color: #666666;
  338. }
  339. }
  340. }
  341. .cm-member-button {
  342. width: 100%;
  343. box-sizing: border-box;
  344. padding: 0 51rpx;
  345. .pay-btn {
  346. width: 100%;
  347. height: 90rpx;
  348. line-height: 90rpx;
  349. border-radius: 50rpx;
  350. text-align: center;
  351. font-size: $font-size-30;
  352. color: #55331d;
  353. box-sizing: border-box;
  354. margin-bottom: $font-size-24;
  355. &.pay {
  356. background: linear-gradient(90deg, #fee9ba 0%, #f0cb72 100%);
  357. font-weight: bold;
  358. }
  359. &.none {
  360. border: 1px solid #f0cb72;
  361. margin-bottom: 0;
  362. }
  363. }
  364. }
  365. }
  366. .cm-model-alert {
  367. width: 100%;
  368. height: 100%;
  369. background: rgba(0, 0, 0, 0.5);
  370. position: fixed;
  371. top: 0;
  372. left: 0;
  373. z-index: 8888;
  374. transition: all 0.4s;
  375. .content {
  376. width: 580rpx;
  377. height: 390rpx;
  378. position: absolute;
  379. background: $bg-color;
  380. left: 0;
  381. right: 0;
  382. bottom: 0;
  383. top: 0;
  384. margin: auto;
  385. padding: 20rpx 32rpx;
  386. border-radius: 12rpx;
  387. .title {
  388. width: 100%;
  389. height: 68rpx;
  390. line-height: 68rpx;
  391. font-size: $font-size-28;
  392. color: $text-color;
  393. text-align: center;
  394. position: relative;
  395. .icon-iconfontguanbi {
  396. width: 68rpx;
  397. height: 68rpx;
  398. text-align: center;
  399. line-height: 68rpx;
  400. position: absolute;
  401. right: 0;
  402. top: 0;
  403. font-size: $font-size-36;
  404. color: #999999;
  405. }
  406. }
  407. .text-content {
  408. width: 100%;
  409. height: auto;
  410. margin-top: 20px;
  411. .text {
  412. padding: 20rpx 0 0 0;
  413. line-height: 44rpx;
  414. font-size: $font-size-26;
  415. color: #666666;
  416. text-align: justify;
  417. .text-p {
  418. color: #FF5B00;
  419. }
  420. }
  421. }
  422. .text-button {
  423. width: 100%;
  424. height: 72rpx;
  425. display: flex;
  426. box-sizing: border-box;
  427. padding: 0 50rpx;
  428. margin-top: 30px;
  429. .btn {
  430. width: 200rpx;
  431. height: 72rpx;
  432. line-height: 72rpx;
  433. color: #fff;
  434. display: flex;
  435. align-items: center;
  436. justify-content: center;
  437. font-size: $font-size-26;
  438. border-radius: 44rpx;
  439. box-sizing: border-box;
  440. &.btn-confirm {
  441. background: $btn-confirm;
  442. margin-left: 78rpx;
  443. }
  444. &.btn-cancel {
  445. border: 1px solid #b2b2b2;
  446. color: #333333;
  447. }
  448. }
  449. }
  450. }
  451. }
  452. </style>