1
0

vip-card.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <app-layout>
  3. <view class="page" v-if="card">
  4. <view class="main-card"
  5. :style="{
  6. backgroundImage: `url(${appImg.vip_card.default_card})`,
  7. }">
  8. <view class="name">{{card.name}}</view>
  9. <view style="margin-bottom: 24rpx">开通超级会员可以享受以下权益</view>
  10. <view class="dir-left-nowrap cross-center">
  11. <image src="/static/image/icon/vip-card-coupon.png"
  12. style="width: 42rpx; height: 30rpx; margin-right: 18rpx"></image>
  13. <view style="margin-right: 50rpx">{{card.discount == 0 ? '免费' : card.discount + '折'}}</view>
  14. <template v-if="card.is_free_delivery == 1 || true">
  15. <image src="/static/image/icon/vip-card-delivery.png"
  16. style="width: 38rpx; height: 32rpx; margin-right: 18rpx"></image>
  17. <view style="margin-right: 32rpx">自营商品包邮</view>
  18. </template>
  19. <view @click="navigateVipCardPrivilege" style="color: #b17426;">
  20. <text>查看权益 ></text>
  21. </view>
  22. </view>
  23. </view>
  24. <view v-for="(item, index) in card.detail"
  25. :key="index"
  26. @tap="active(index)"
  27. class="child-card dir-left-nowrap cross-center"
  28. :class="[item.active?'active':'']">
  29. <view class="box-grow-1">
  30. <view style="margin-bottom: 12rpx;">{{item.name}}</view>
  31. <view class="dir-left-nowrap" style="font-size: 24rpx;">
  32. <view v-if="item.active"
  33. @tap.stop="showDesc(item)"
  34. class="dir-left-nowrap cross-center">
  35. <view style="color: #ffb85d;margin-right: 8rpx; font-size: 22rpx; line-height: 1.05;">使用说明
  36. </view>
  37. <app-css-icon icon="arrow-right" size="22" padding round color="#fff"
  38. background="#ffb85d"></app-css-icon>
  39. </view>
  40. <view v-else
  41. @tap.stop="showDesc(item)"
  42. class="dir-left-nowrap cross-center">
  43. <view style="color: #999;margin-right: 8rpx; font-size: 22rpx; line-height: 1.05;">使用说明
  44. </view>
  45. <app-css-icon icon="arrow-right" size="22" padding round color="#fff"
  46. background="#999"></app-css-icon>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="box-grow-0 dir-left-nowrap cross-center" :class="theme">
  51. <view class="price" :class="[`${theme} ${theme}-m-text`]"
  52. style="margin-right: 24rpx">
  53. ¥{{item.price}}
  54. </view>
  55. <view v-if="item.active" class="checkbox"
  56. :class="[`${theme} ${theme}-m-back ${theme}-m-border`]">
  57. <app-css-icon v-if="item.active"
  58. icon="check"
  59. :size="28"
  60. color="#fff"
  61. transform="translate(28%, -15%)"></app-css-icon>
  62. </view>
  63. <view v-else class="checkbox border-gray"></view>
  64. </view>
  65. </view>
  66. <view class="submit-bar dir-left-nowrap">
  67. <view class="box-grow-1 cross-center price"
  68. :class="[`${theme} ${theme}-m-text`]">
  69. <template v-if="selectedCard">开卡费用:¥{{selectedCard.price}}</template>
  70. <template v-else>请选择需要开通的子卡</template>
  71. </view>
  72. <view @click="setData"
  73. class="box-grow-0 cross-center submit-btn"
  74. :class="[`${theme} ${theme}-m-back`]">提交
  75. </view>
  76. </view>
  77. <app-dialog :title="descDialog.title"
  78. :content="descDialog.content"
  79. confirm-text="我知道了"
  80. :visible.sync="descDialog.visible"></app-dialog>
  81. </view>
  82. </app-layout>
  83. </template>
  84. <script>
  85. import {mapGetters} from 'vuex';
  86. import AppCheckBox from "../../components/basic-component/app-check-box/app-check-box";
  87. import AppDialog from "./app-dialog";
  88. export default {
  89. name: 'vip-card',
  90. components: {AppDialog, AppCheckBox},
  91. data() {
  92. return {
  93. mchIndex: null,
  94. card: null,
  95. selectedCard: null,
  96. list: null,
  97. descDialog: {
  98. title: '',
  99. content: '',
  100. visible: false,
  101. },
  102. };
  103. },
  104. computed: {
  105. ...mapGetters({
  106. appImg: 'mallConfig/getWxappImg',
  107. theme: 'mallConfig/getTheme',
  108. }),
  109. },
  110. onLoad(options) {
  111. this.mchIndex = options.mchIndex;
  112. this.loadData();
  113. setTimeout(() => {
  114. this.list = [1, 2, 3];
  115. }, 500);
  116. },
  117. methods: {
  118. navigateVipCardPrivilege() {
  119. uni.navigateTo({
  120. url: '/plugins/vip_card/rights/rights?id=1',
  121. });
  122. },
  123. loadData() {
  124. uni.showNavigationBarLoading({});
  125. this.$request({
  126. url: this.$api.vip_card.card,
  127. }).then(e => {
  128. uni.hideNavigationBarLoading({});
  129. if (e.code === 0) {
  130. for (let i in e.data.detail) {
  131. e.data.detail[i].active = false;
  132. }
  133. this.card = e.data;
  134. this.setActive();
  135. }
  136. }).catch(e => {
  137. uni.hideNavigationBarLoading({});
  138. });
  139. },
  140. active(index) {
  141. if (this.card.detail[index].active) {
  142. // 取消操作
  143. this.selectedCard = null;
  144. this.card.detail[index].active = false;
  145. } else {
  146. for (let i in this.card.detail) {
  147. if (parseInt(i) === parseInt(index)) {
  148. this.selectedCard = this.card.detail[i];
  149. this.card.detail[i].active = true;
  150. } else {
  151. this.card.detail[i].active = false;
  152. }
  153. }
  154. }
  155. },
  156. showDesc(item) {
  157. this.descDialog.title = item.title;
  158. this.descDialog.content = item.content;
  159. this.descDialog.visible = true;
  160. },
  161. setActive() {
  162. const formData = this.$store.state.orderSubmit.formData;
  163. const id = formData.list[this.mchIndex].vip_card_detail_id;
  164. if (!id) return;
  165. for (let i in this.card.detail) {
  166. if (parseInt(this.card.detail[i].id) === parseInt(id)) {
  167. this.card.detail[i].active = true;
  168. this.selectedCard = this.card.detail[i];
  169. }
  170. }
  171. },
  172. setData() {
  173. const formData = this.$store.state.orderSubmit.formData;
  174. if (this.selectedCard) {
  175. formData.list[this.mchIndex].vip_card_detail_id = parseInt(this.selectedCard.id);
  176. } else {
  177. formData.list[this.mchIndex].vip_card_detail_id = null;
  178. }
  179. this.$store.commit('orderSubmit/mutSetFormData', formData);
  180. uni.navigateBack();
  181. },
  182. }
  183. }
  184. </script>
  185. <style lang="scss">
  186. page {
  187. background: $uni-weak-color-two;
  188. }
  189. .page {
  190. padding-bottom: #{120rpx};
  191. }
  192. .main-card,
  193. .child-card {
  194. padding: #{56rpx};
  195. border-radius: #{16rpx};
  196. margin: #{24rpx};
  197. }
  198. .main-card {
  199. background: #d6aa84;
  200. color: #342e25;
  201. background-size: 100% 100%;
  202. height: #{361rpx};
  203. font-size: #{24rpx};
  204. margin-bottom: #{30rpx};
  205. box-shadow: 0 0 #{24rpx} rgba(0, 0, 0, .15);
  206. .name {
  207. font-size: #{40rpx};
  208. margin-bottom: #{32rpx};
  209. }
  210. }
  211. .child-card {
  212. background: #fff;
  213. position: relative;
  214. overflow: hidden;
  215. z-index: 1;
  216. border: #{1rpx} solid #e5e5e5;
  217. .price {
  218. font-size: #{40rpx};
  219. font-weight: bold;
  220. }
  221. }
  222. .submit-bar {
  223. position: fixed;
  224. z-index: 100;
  225. left: 0;
  226. bottom: 0;
  227. width: 100%;
  228. background: #fff;
  229. height: #{100rpx};
  230. border-top: #{1rpx} solid rgba(0, 0, 0, 0.1);
  231. .price {
  232. padding: 0 #{24rpx};
  233. }
  234. .submit-btn {
  235. padding: 0 #{48rpx};
  236. color: #fff;
  237. }
  238. }
  239. .checkbox {
  240. width: #{46rpx};
  241. height: #{46rpx};
  242. border-radius: #{1000rpx};
  243. border-width: #{2rpx};
  244. border-style: solid;
  245. }
  246. .checkbox.border-gray {
  247. border-color: #ccc;
  248. }
  249. </style>