upgrade.vue 9.3 KB

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