member.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. <template>
  2. <view class="container">
  3. <view class="member">
  4. <view class="portrait"><image :src="userInfo.avatar"></image></view>
  5. <view class="name">{{userInfo.nickname}}</view>
  6. <view class="status" v-if="userInfo.level_info.grade == 100">你已开通美卡</view>
  7. <view class="status" v-if="userInfo.level_info.grade < 100">尚未开通美卡</view>
  8. </view>
  9. <view class="assets">
  10. <view class="title">
  11. <image class="" src="/static/img/img33.png"></image>
  12. <view class="name">
  13. 开通
  14. <text>VIP</text>
  15. 即可尊享美卡专属特权
  16. </view>
  17. </view>
  18. <view class="privileges flex">
  19. <view class="privileges_list" v-for="ls in list">
  20. <view class="img"><image :src="ls.img"></image></view>
  21. <view class="text">{{ ls.text }}</view>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="card">
  26. <view class="card-box" v-bind:class="{ active_card_box: ls.id == current }" v-for="ls in card" @click="change(ls.id)">
  27. <view class="title">{{ ls.title }}</view>
  28. <view class="price" v-bind:class="{ active_price: ls.id == current }">
  29. <text>{{ ls.price }}</text>
  30. </view>
  31. <view class="ot-price">¥{{ ls.ot_price }}</view>
  32. <view class="icon">
  33. <text v-bind:class="{ active_icon: ls.id == current }">{{ ls.text }}</text>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="method">
  38. <view class="pay">支付方式</view>
  39. <view class="method-list">
  40. <radio-group @change="tabRadio">
  41. <label>
  42. <view class="box">
  43. <uni-icons type="weixin" color="#00B848" size="25" />
  44. <view class="title-box">
  45. <view class="title"><text>微信支付</text></view>
  46. </view>
  47. <view class="right"><radio value="weixin" size='25' color="#5dbc7c" :checked="type == 'weixin'" /></view>
  48. </view>
  49. </label>
  50. </radio-group>
  51. </view>
  52. </view>
  53. <view class="checkbox">
  54. <radio @click="checked = !checked" color="#06B163" :checked="checked" />已阅读并同意
  55. <text>《美卡会员服务协议》</text>
  56. </view>
  57. <view class="submit" :class="{ clickbg: payLoding }" @click="!payLoding ? submit() : ''">立即支付</view>
  58. </view>
  59. </template>
  60. <script>
  61. import {recharge } from '@/api/user.js';
  62. import { getUserInfo } from '@/api/login.js';
  63. import checkbox from '@/components/evan-checkbox/evan-checkbox.vue'
  64. import { mapState } from 'vuex';
  65. export default {
  66. data() {
  67. return {
  68. current: 5,
  69. userInfo: '',
  70. type: 'weixin', //提现方式
  71. checked:false,
  72. payLoding: false, //判断是否支付中
  73. list: [
  74. {
  75. img: '/static/img/img51.png',
  76. text: '美卡专享价'
  77. },
  78. {
  79. img: '/static/img/img52.png',
  80. text: '美卡优惠卡包'
  81. },
  82. {
  83. img: '/static/img/img53.png',
  84. text: '免配送券'
  85. },
  86. {
  87. img: '/static/img/img54.png',
  88. text: '更多'
  89. }
  90. ],
  91. card: [
  92. {
  93. id: '5',
  94. title: '年卡',
  95. price: '88',
  96. ot_price: '298',
  97. text: '立省880元'
  98. }
  99. ]
  100. };
  101. },
  102. onLoad() {
  103. this.loadDate();
  104. },
  105. computed: {
  106. // #ifdef H5
  107. ...mapState(['weichatObj'])
  108. // #endif
  109. },
  110. onShow() {},
  111. methods: {
  112. loadDate() {
  113. getUserInfo({}).then(({ data }) => {
  114. this.userInfo = data;
  115. });
  116. },
  117. //提交美卡
  118. submit(){
  119. let obj =this;
  120. if(obj.checked == false){
  121. obj.$api.msg('请先阅读并同意美卡服务协议');
  122. return;
  123. }
  124. // 支付中
  125. obj.payLoding = true;
  126. recharge({
  127. level_id:3,
  128. spread:obj.userInfo.spread_uid
  129. }).then(( data ) => {
  130. console.log(data,'jsConfig')
  131. let da = e.data.result.jsConfig;
  132. let dataConfig = {
  133. // #ifdef H5
  134. timestamp: da.timestamp,
  135. // #endif
  136. // #ifdef MP
  137. timeStamp: da.timestamp,
  138. // #endif
  139. nonceStr: da.nonceStr,
  140. package: da.package,
  141. signType: da.signType,
  142. paySign: da.paySign,
  143. success: function(res) {
  144. uni.showToast({
  145. title: '开通美卡成功!',
  146. type: 'top',
  147. duration: 500,
  148. icon: 'none'
  149. });
  150. },
  151. fail: () => {
  152. uni.showToast({
  153. title: '支付失败!',
  154. type: 'top',
  155. duration: 500,
  156. icon: 'none'
  157. });
  158. }
  159. };
  160. // #ifdef H5
  161. obj.weichatObj.chooseWXPay(dataConfig);
  162. // #endif
  163. obj.payLoding = false;
  164. }).catch(e => {
  165. obj.payLoding = false;
  166. console.log(e);
  167. });
  168. },
  169. //商品种类切换
  170. change(item) {
  171. let id = item;
  172. this.current = id;
  173. },
  174. checkbox(e){
  175. this.checked = e;
  176. },
  177. // 切换选中对象
  178. tabRadio(e) {
  179. this.type = e.detail.value;
  180. }
  181. }
  182. };
  183. </script>
  184. <style lang="scss">
  185. page {
  186. height: 100%;
  187. background-color: #ffffff;
  188. .container {
  189. height: 100%;
  190. }
  191. }
  192. .clickbg {
  193. background-color: $color-gray !important;
  194. }
  195. .member {
  196. background: #1c2532;
  197. width: 100%;
  198. text-align: center;
  199. color: #ffffff;
  200. padding: 64rpx 0rpx;
  201. .portrait {
  202. width: 100%;
  203. height: 120rpx;
  204. text-align: center;
  205. border-radius: 100%;
  206. image {
  207. width: 120rpx;
  208. height: 100%;
  209. border-radius: 100%;
  210. }
  211. }
  212. .name {
  213. padding-top: 38rpx;
  214. }
  215. .status {
  216. font-size: 24rpx;
  217. padding-top: 12rpx;
  218. }
  219. }
  220. .assets {
  221. background: #ffffff;
  222. width: 100%;
  223. padding: 35rpx 0rpx;
  224. text-align: center;
  225. .title {
  226. width: 100%;
  227. height: 3rpx;
  228. margin: 0rpx auto;
  229. image {
  230. width: 100%;
  231. height: 100%;
  232. }
  233. .name {
  234. position: relative;
  235. bottom: 35rpx;
  236. font-size: 24rpx;
  237. color: #2a3344;
  238. text {
  239. font-size: 43rpx;
  240. font-weight: bold;
  241. font-style: italic;
  242. }
  243. }
  244. }
  245. .list {
  246. margin-top: 100rpx;
  247. padding: 0rpx 120rpx;
  248. font-size: 24rpx;
  249. margin-bottom: 40rpx;
  250. .tpl {
  251. color: #666666;
  252. .tip {
  253. font-size: 40rpx;
  254. font-weight: bold;
  255. color: #303133;
  256. padding-bottom: 15rpx;
  257. text {
  258. font-size: 24rpx;
  259. font-weight: normal;
  260. }
  261. }
  262. }
  263. }
  264. .privileges {
  265. margin-top: 100rpx;
  266. font-size: 24rpx;
  267. margin-bottom: 40rpx;
  268. padding: 0rpx 42rpx;
  269. .privileges_list {
  270. text-align: center;
  271. .img {
  272. height: 80rpx;
  273. text-align: center;
  274. image {
  275. width: 80rpx;
  276. height: 100%;
  277. }
  278. }
  279. .text {
  280. padding-top: 15rpx;
  281. }
  282. }
  283. }
  284. }
  285. .card {
  286. width:225rpx;
  287. margin: 0rpx auto;
  288. .active_card_box {
  289. background: #faf3d7 !important;
  290. }
  291. .card-box {
  292. background: #ffffff;
  293. border: 2rpx solid rgba(251, 232, 157, 1);
  294. text-align: center;
  295. padding: 45rpx 25rpx;
  296. border-radius: 25rpx;
  297. .title {
  298. font-size: 32rpx;
  299. font-weight: 500;
  300. padding-bottom: 15rpx;
  301. }
  302. .price {
  303. font-weight: bold;
  304. color: #333333;
  305. font-size: 41rpx;
  306. text {
  307. font-size: 66rpx;
  308. }
  309. }
  310. .active_price {
  311. color: #ff383e;
  312. }
  313. .ot-price {
  314. color: #9a5a12;
  315. font-size: 33rpx;
  316. font-weight: 500;
  317. // text-decoration:line-through;
  318. color: rgba(154, 90, 18, 1);
  319. opacity: 0.35;
  320. }
  321. .icon {
  322. text {
  323. border: 2rpx solid #ff383e;
  324. color: #ff383e;
  325. font-size: 22rpx;
  326. padding: 15rpx 25rpx;
  327. border-radius: 25rpx;
  328. }
  329. .active_icon {
  330. background-color: #ff383e;
  331. border: none;
  332. color: #ffffff;
  333. }
  334. }
  335. }
  336. }
  337. .method {
  338. margin-top: 80rpx;
  339. .pay {
  340. padding-left: 25rpx;
  341. font-weight:bold;
  342. color:rgba(51,51,51,1);
  343. font-size: 32rpx;
  344. }
  345. .method-list {
  346. padding-left: 30rpx;
  347. padding-right: 30rpx;
  348. margin-top: 30rpx;
  349. background-color: #ffffff;
  350. .box {
  351. display: flex;
  352. align-items: center;
  353. width: 100%;
  354. height: 120rpx;
  355. border-bottom: 1px solid $border-color-light;
  356. border-top: 1px solid $border-color-light;
  357. .icon {
  358. font-size: 48rpx;
  359. padding-right: 20rpx;
  360. .icon-img {
  361. height: 50rpx;
  362. width: 50rpx;
  363. }
  364. }
  365. .title-box {
  366. flex-grow: 1;
  367. text-align: left;
  368. padding-left: 15rpx;
  369. .title {
  370. font-size: 32rpx;
  371. color: #333333;
  372. }
  373. .node {
  374. font-size: $font-sm;
  375. color: $font-color-light;
  376. }
  377. }
  378. }
  379. }
  380. }
  381. .checkbox{
  382. width: 100%;
  383. padding: 50rpx 55rpx;
  384. margin-top: 150rpx;
  385. font-size: 24rpx;
  386. text{
  387. color: #29CC66;
  388. }
  389. }
  390. .submit{
  391. width: 88%;
  392. margin: 0rpx auto;
  393. background:linear-gradient(180deg,rgba(0,184,72,1),rgba(44,230,114,1));
  394. border-radius:40px;
  395. color: #FFFFFF;
  396. text-align: center;
  397. padding: 20rpx 0rpx;
  398. margin-bottom: 60rpx !important;
  399. }
  400. </style>