upgrade.vue 9.1 KB

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