upgrade.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. <template>
  2. <app-layout>
  3. <view class="nav">
  4. <swiper class='member-list' :current="index" @change="change" previous-margin='20px' next-margin="20px">
  5. <swiper-item class='member-item' v-for="item in list" :key="item.id">
  6. <!-- #ifdef MP-ALIPAY -->
  7. <image class='memeber-img' :src='item.bg_pic_url ? item.bg_pic_url : item.pic_url'
  8. style="margin-top: 0"></image>
  9. <!-- #endif -->
  10. <!-- #ifndef MP-ALIPAY -->
  11. <image class='memeber-img' :src='item.bg_pic_url ? item.bg_pic_url : item.pic_url'></image>
  12. <!-- #endif -->
  13. </swiper-item>
  14. </swiper>
  15. </view>
  16. <view class='method' v-if="detail.is_purchase != 0 || detail.auto_update != 0">
  17. <view class='member-info'>
  18. <view>{{detail.name}}</view>
  19. </view>
  20. <view class='method-title'>
  21. <image src='./../image/how.png'></image>
  22. <text>如何获得该卡</text>
  23. </view>
  24. <view class='method-list'>
  25. <view class="dir-left cross-center way" v-if="detail.is_purchase != 0">
  26. <image class="way-num" :src='memberImg.one'></image>
  27. <view class='way-money'>直接购买
  28. <text>¥{{detail.price}}</text>
  29. </view>
  30. </view>
  31. <view class="dir-left cross-center way" v-if="detail.auto_update != 0">
  32. <image class="way-num" v-if="detail.is_purchase != 0" :src='memberImg.two'></image>
  33. <image class="way-num" v-else :src='memberImg.one'></image>
  34. <view class="way-money">累积消费满
  35. <text>¥{{detail.money}}</text>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <view class='right'>
  41. <view class='method-title'>
  42. <image src='./../image/right.png'></image>
  43. <text>特权说明</text>
  44. </view>
  45. <view class='right-list'>
  46. <view v-for="item in detail.rights" :key="item.id">{{item.content}}</view>
  47. </view>
  48. </view>
  49. <view class='right-away' v-if="detail.is_purchase == 1 && detail.level > level">
  50. <view class="to-recharge" @click="payMember(detail.level,1)">
  51. <button class='way-btn'>¥{{detail.price}} 立即升级</button>
  52. </view>
  53. </view>
  54. <view class='right-away' v-else-if="detail.level == level">
  55. <view class="to-recharge" @click="payMember(detail.level,2)">
  56. <button class='way-btn'>¥{{detail.price}} 立即续费</button>
  57. </view>
  58. </view>
  59. </app-layout>
  60. </template>
  61. <script>
  62. import {
  63. mapGetters,
  64. mapState
  65. } from "vuex";
  66. export default {
  67. data() {
  68. return {
  69. auto: false,
  70. list: [],
  71. index: 0,
  72. level: 0,
  73. other: 0,
  74. current: 'wechat',
  75. detail: {
  76. price: '',
  77. money: ''
  78. },
  79. }
  80. },
  81. name: "upgrade",
  82. computed: {
  83. ...mapState({
  84. memberImg: state => state.mallConfig.__wxapp_img.member,
  85. })
  86. },
  87. methods: {
  88. payMember(member_level, type) {
  89. let that = this;
  90. uni.showLoading({
  91. title: '领取中...'
  92. });
  93. that.$request({
  94. url: that.$api.member.purchase,
  95. data: {
  96. member_level: member_level,
  97. type: type
  98. },
  99. method: 'post'
  100. }).then(response => {
  101. uni.hideLoading();
  102. if (response.code === 0) {
  103. if (response.data.retry && response.data.retry === 1) {
  104. that.getPayDataTimer = setTimeout(() => {
  105. that.payMember(member_level);
  106. }, 1000);
  107. } else {
  108. that.pay(response.data.pay_id, member_level);
  109. }
  110. } else {
  111. uni.showModal({
  112. title: '提示',
  113. content: response.msg,
  114. showCancel: false,
  115. });
  116. }
  117. }).catch(e => {
  118. uni.hideLoading();
  119. uni.showModal({
  120. title: '提示',
  121. content: e.errMsg,
  122. showCancel: false,
  123. });
  124. });
  125. },
  126. pay(id, level) {
  127. let that = this;
  128. that.$payment.pay(id).then(res => {
  129. uni.showToast({
  130. title: '支付成功',
  131. duration: 1000
  132. });
  133. that.level = level;
  134. that.$store.dispatch('user/refreshMember', that.detail.level, that.detail.name);
  135. }).catch(res => {
  136. uni.showToast({
  137. title: '支付失败',
  138. icon: 'none',
  139. duration: 1000
  140. });
  141. });
  142. },
  143. change(e) {
  144. let that = this;
  145. that.index = e.detail.current;
  146. that.detail = that.list[that.index];
  147. },
  148. getList() {
  149. let that = this;
  150. that.$request({
  151. url: that.$api.member.all,
  152. method: 'get',
  153. }).then(response => {
  154. uni.hideLoading();
  155. that.$hideLoading();
  156. if (response.code == 0) {
  157. that.list = response.data.list;
  158. that.index = 0;
  159. if (that.other > 0) {
  160. for (let i = 0; i < that.list.length; i++) {
  161. if (that.other == that.list[i].level) {
  162. that.index = i;
  163. }
  164. }
  165. } else {
  166. for (let i = 0; i < that.list.length; i++) {
  167. if (that.level == that.list[i].level) {
  168. that.index = i;
  169. }
  170. }
  171. }
  172. that.detail = that.list[that.index];
  173. } else {
  174. uni.showToast({
  175. title: response.msg,
  176. icon: 'none',
  177. duration: 1000
  178. });
  179. }
  180. }).catch(response => {
  181. uni.hideLoading();
  182. that.$hideLoading();
  183. });
  184. },
  185. },
  186. onLoad(options) {
  187. let that = this;
  188. if (options.level) {
  189. that.level = options.level
  190. }
  191. if (options.other) {
  192. that.other = options.other
  193. }
  194. that.$showLoading({
  195. text: '加载中...'
  196. });
  197. that.getList();
  198. },
  199. }
  200. </script>
  201. <style scoped lang="scss">
  202. .nav {
  203. margin-top: #{32rpx};
  204. position: relative;
  205. text-align: center;
  206. height: #{370rpx};
  207. image {
  208. margin-top: #{20rpx};
  209. height: #{330rpx};
  210. width: #{640rpx};
  211. border-radius: #{16rpx};
  212. box-shadow: 0 0 #{20rpx} rgba(0, 0, 0, 0.3);
  213. }
  214. .to-recharge {
  215. position: absolute;
  216. bottom: #{102rpx};
  217. left: 0;
  218. right: 0;
  219. margin: 0 auto;
  220. height: #{70rpx};
  221. width: #{240rpx};
  222. }
  223. }
  224. .member-list {
  225. height: #{370rpx};
  226. }
  227. .upgrade-btn {
  228. height: #{70rpx};
  229. line-height: #{68rpx};
  230. width: #{240rpx};
  231. border: #{1rpx} solid #b4914f;
  232. border-radius: #{36rpx};
  233. font-size: #{32rpx};
  234. color: #b4914f;
  235. background-color: #f8f2e2;
  236. }
  237. .method {
  238. margin-top: #{96rpx};
  239. }
  240. .member-info {
  241. font-size: #{36rpx};
  242. color: #353535;
  243. padding: 0 #{55rpx};
  244. margin-bottom: #{40rpx};
  245. }
  246. .method-title {
  247. height: #{48rpx};
  248. font-size: #{32rpx};
  249. color: #353535;
  250. padding: 0 #{55rpx};
  251. }
  252. .method-title image {
  253. height: #{48rpx};
  254. width: #{48rpx};
  255. float: left;
  256. margin-right: #{40rpx};
  257. }
  258. .method-list {
  259. margin-top: #{32rpx};
  260. margin-left: #{143rpx};
  261. }
  262. .way-num {
  263. height: #{36rpx};
  264. width: #{36rpx};
  265. display: block;
  266. margin-top: #{8rpx};
  267. margin-right: #{16rpx};
  268. }
  269. .way {
  270. height: #{60rpx};
  271. line-height: #{60rpx};
  272. }
  273. .way-money {
  274. font-size: #{32rpx};
  275. color: #353535;
  276. }
  277. .way-money text {
  278. font-size: #{36rpx};
  279. color: #b4914f;
  280. font-family: DIN
  281. }
  282. .right {
  283. margin-top: #{64rpx};
  284. padding-bottom: #{150rpx};
  285. }
  286. .right-list {
  287. margin-left: #{143rpx};
  288. color: #666;
  289. font-size: #{28rpx};
  290. width: #{540rpx};
  291. }
  292. .right-away {
  293. height: #{140rpx};
  294. position: fixed;
  295. bottom: 0;
  296. left: 0;
  297. right: 0;
  298. background-color: #ffffff;
  299. .way-btn {
  300. margin: #{30rpx} auto 0;
  301. height: #{80rpx};
  302. line-height: #{80rpx};
  303. width: #{640rpx};
  304. background-color: #b4914f;
  305. border-radius: #{40rpx};
  306. font-size: #{32rpx};
  307. color: #ffffff;
  308. }
  309. }
  310. .member-name {
  311. position: absolute;
  312. text-align: center;
  313. left: 0;
  314. right: 0;
  315. font-size: #{44rpx};
  316. color: #fff;
  317. top: #{85rpx};
  318. }
  319. .memeber-info {
  320. display: none;
  321. }
  322. </style>