index.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. <template>
  2. <view class="content">
  3. <view class="top">
  4. <view class="text" v-if="member_date!==''">会员与{{member_date}}过期</view>
  5. <view class="text" v-else>开通会员,立享多种特权</view>
  6. </view>
  7. <view class="box">
  8. <view class="title">全年VIP</view>
  9. <view class="price">¥{{price}}<span style="font-size: 40rpx;">/年</span></view>
  10. <view class="title" style="margin: 36rpx 0 20rpx;">会员权益</view>
  11. <view class="conent">
  12. <u-parse :content="text"></u-parse>
  13. </view>
  14. </view>
  15. <view class="bottom">
  16. <view class="hflex acenter">
  17. <u-checkbox-group @change="checkboxChange">
  18. <u-checkbox v-model="agree" shape="circle"></u-checkbox>
  19. </u-checkbox-group>
  20. <view class="text">已阅读并同意<span class="read" @click="opens">《会员服务协议》</span></view>
  21. </view>
  22. <view class="button hflex acenter jcenter" @click="openMember">
  23. <view>确定协议并开通</view>
  24. </view>
  25. </view>
  26. <u-popup :show="pay_show" @close="close" mode="bottom" :round="20" :closeable="true">
  27. <view class="popup">
  28. <view class="title">立即支付</view>
  29. <view class="price">¥{{price}}</view>
  30. <!-- <view class="text1">支付方式</view> -->
  31. <view class="vflex">
  32. <u-checkbox-group @change="checkboxChange1" placement="column">
  33. <view class="box1 hflex acenter jbetween">
  34. <view class="hflex acenter">
  35. <image src="/static/images/shop/wx_pay.png" style="width: 48rpx;height: 48rpx;"></image>
  36. <view class="box_right">微信支付</view>
  37. </view>
  38. <u-checkbox name="0" shape="circle"></u-checkbox>
  39. </view>
  40. <view class="box1 hflex acenter jbetween">
  41. <view class="hflex acenter">
  42. <image src="/static/images/shop/yue_pay.png" style="width: 48rpx;height: 48rpx;"></image>
  43. <view class="box_right">余额支付(¥{{amount}})</view>
  44. </view>
  45. <view class="hflex acenter">
  46. <view class="info" v-if="combination">{{info}}</view>
  47. <u-checkbox name="1" shape="circle" :disabled="disabled"></u-checkbox>
  48. </view>
  49. </view>
  50. </u-checkbox-group>
  51. </view>
  52. <view class="btn" @click="pay">立即支付</view>
  53. </view>
  54. </u-popup>
  55. </view>
  56. </template>
  57. <script>
  58. import $api from '@/static/js/api.js'
  59. var that = ''
  60. export default {
  61. data() {
  62. return {
  63. text: '',
  64. agree: false,
  65. agree1: '',
  66. pay_show: false,
  67. price: 0,
  68. member_date: '',
  69. amount: '',
  70. info: '需组合支付',
  71. checkValue: [
  72. {
  73. name:'wx',
  74. },
  75. {
  76. name: 'yue'
  77. }
  78. ],
  79. data: '',
  80. pay_data: [],
  81. combination: false,
  82. is_vip: 0,
  83. disabled: false
  84. }
  85. },
  86. onLoad() {
  87. that = this
  88. that.getData()
  89. },
  90. methods: {
  91. getData() {
  92. $api.req({
  93. url: '/data/api.auth.Center/getvipinfo',
  94. method: 'POST',
  95. }, function(res) {
  96. if(res.code == 1) {
  97. that.price = res.data.price
  98. that.text = res.data.user_vip_des
  99. that.data = res.data.user_vip_agreement
  100. var pages = getCurrentPages()
  101. var prePage = pages[pages.length - 2]
  102. that.member_date = prePage.$vm.user.vip_datetime
  103. that.amount = prePage.$vm.user.money
  104. if(that.amount==0) {
  105. that.disabled = true
  106. that.combination = false
  107. } else if(Number(that.amount) < Number(that.price)) {
  108. that.combination = true
  109. }
  110. that.is_vip = prePage.$vm.user.is_vip
  111. }
  112. })
  113. },
  114. // 阅读并同意
  115. checkboxChange(n) {
  116. this.agree = !this.agree
  117. },
  118. // 选择支付方式
  119. checkboxChange1(n) {
  120. console.log(n);
  121. this.agree1 = n
  122. },
  123. // 确定协议并开通
  124. openMember() {
  125. if(that.agree) {
  126. that.pay_show = true
  127. } else {
  128. $api.info('请先阅读并同意《会员服务协议》')
  129. }
  130. },
  131. opens() {
  132. uni.setStorageSync('xieyi',that.data)
  133. $api.jump('/pages/user/agreement?title=会员服务协议')
  134. console.log(that.data);
  135. },
  136. // 关闭弹窗
  137. close() {
  138. that.pay_show = false
  139. },
  140. // 立即支付
  141. pay() {
  142. console.log(that.agree1);
  143. if (that.agree1) {
  144. $api.req({
  145. url: '/data/api.auth.Center/channel',
  146. method: 'POST',
  147. data: {
  148. type: 1,
  149. from: 1
  150. }
  151. }, function(res) {
  152. if(res.code == 1) {
  153. var data = {}
  154. if(that.agree1[0] == '0' && that.agree1.length == 1) {
  155. var payment = res.data[0]
  156. data = {
  157. pay_code: payment.code
  158. }
  159. $api.req({
  160. url: '/data/api.auth.Center/openvip',
  161. method: 'POST',
  162. data: data,
  163. }, function(res) {
  164. if(res.code == 1) {
  165. wx.requestPayment({
  166. timeStamp: res.data.pay.timeStamp,
  167. nonceStr: res.data.pay.nonceStr,
  168. package: res.data.pay.package,
  169. signType: 'MD5',
  170. paySign: res.data.pay.paySign,
  171. success (res) {
  172. that.close()
  173. $api.info("支付成功")
  174. $api.jump('/pages/tabbar/mine/mine',3)
  175. // that.getData()
  176. },
  177. fail (res) {
  178. that.close()
  179. // $api.info('支付失败')
  180. }
  181. })
  182. /* if(res.data.success == 0) {
  183. $api.info('支付失败')
  184. } */
  185. }
  186. })
  187. }
  188. else if(!that.combination) {
  189. var payment = res.data[1]
  190. data = {
  191. pay_code: payment.code
  192. }
  193. $api.req({
  194. url: '/data/api.auth.Center/openvip',
  195. method: 'POST',
  196. data: data,
  197. }, function(res) {
  198. if(res.code == 1) {
  199. $api.info("支付成功")
  200. $api.jump('/pages/tabbar/mine/mine',3)
  201. that.close()
  202. }
  203. })
  204. } else {
  205. data = {
  206. pay_code: res.data[1].code,
  207. difference_pay_code: res.data[0].code
  208. }
  209. $api.req({
  210. url: '/data/api.auth.Center/openvip',
  211. method: 'POST',
  212. data: data,
  213. }, function(res) {
  214. if(res.code == 1) {
  215. for(var i=0;i<that.agree1.length;i++) {
  216. if(that.agree1[i] == '0') {
  217. wx.requestPayment({
  218. timeStamp: res.data.pay.timeStamp,
  219. nonceStr: res.data.pay.nonceStr,
  220. package: res.data.pay.package,
  221. signType: 'MD5',
  222. paySign: res.data.pay.paySign,
  223. success (res) {
  224. that.close()
  225. $api.info("支付成功")
  226. $api.jump('/pages/tabbar/mine/mine',3)
  227. // that.getData()
  228. },
  229. fail (res) {
  230. that.close()
  231. // $api.info('支付失败')
  232. }
  233. })
  234. }
  235. }
  236. /* if(res.data.success == 0) {
  237. $api.info('支付失败')
  238. } */
  239. }
  240. })
  241. }
  242. }
  243. })
  244. } else {
  245. $api.info('请先选择支付方式')
  246. }
  247. }
  248. },
  249. }
  250. </script>
  251. <style lang="scss" scoped>
  252. .content {
  253. background-color: #e4e8f4;
  254. .top {
  255. background: url('https://ship-expert.zhousi.hdlkeji.com/common/member_bg.png') no-repeat;
  256. background-size: 100%;
  257. width: 100%;
  258. height: 480rpx;
  259. .text {
  260. font-size: 26rpx;
  261. color: #fff;
  262. padding: 332rpx 0 0 84rpx;
  263. }
  264. }
  265. .box {
  266. width: 100%;
  267. min-height: calc(100vh - 480rpx);
  268. background-color: #fff;
  269. border-radius: 40rpx 40rpx 0 0;
  270. box-sizing: border-box;
  271. padding: 36rpx 30rpx;
  272. margin-bottom: 246rpx;
  273. .title {
  274. font-size: 40rpx;
  275. color: #444;
  276. }
  277. .conent {
  278. width: 100%;
  279. }
  280. .price {
  281. font-size: 60rpx;
  282. color: #ff2626;
  283. padding:34rpx 0 52rpx;
  284. border-bottom: 1rpx solid #f2f2f2;
  285. }
  286. }
  287. .bottom {
  288. width: 100%;
  289. height: 246rpx;
  290. background-color: #fff;
  291. box-shadow: 0 -2rpx 16rpx 0 rgba(215,215,215,0.5);
  292. position: fixed;
  293. bottom: 0;
  294. box-sizing: border-box;
  295. padding: 36rpx 30rpx;
  296. .text {
  297. font-size: 24rpx;
  298. color: #9c9c9c;
  299. }
  300. .read {
  301. color: #2a63f3;
  302. }
  303. .button {
  304. width: 690rpx;
  305. height: 96rpx;
  306. background-color: #506dff;
  307. border-radius: 50rpx;
  308. box-shadow: 0 4rpx 28rpx 0 rgba(132,123,255,0.4);
  309. font-size: 40rpx;
  310. color: #fff;
  311. margin: 40rpx 0 36rpx;
  312. }
  313. }
  314. .popup {
  315. width: 100%;
  316. box-sizing: border-box;
  317. padding: 48rpx 30rpx;
  318. background-color: #fff;
  319. .title {
  320. width: 100%;
  321. text-align: center;
  322. font-size: 36rpx;
  323. color: #222;
  324. margin-bottom: 50rpx;
  325. }
  326. .price {
  327. width: 100%;
  328. text-align: center;
  329. font-size: 60rpx;
  330. color: #ff2626;
  331. margin-bottom: 36rpx;
  332. }
  333. .text1 {
  334. font-size: 30rpx;
  335. color: #222;
  336. margin-bottom: 28rpx;
  337. }
  338. .box1 {
  339. width: 100%;
  340. box-sizing: border-box;
  341. padding: 36rpx 20rpx;
  342. border-bottom: 1rpx solid #F2F2F2;
  343. // background-color: #f6f6f6;
  344. // border-radius: 20rpx;
  345. margin-top: 20rpx;
  346. .box_img {
  347. width: 48rpx;
  348. height: 48rpx;
  349. }
  350. .box_right {
  351. margin-left: 20rpx;
  352. font-size: 26rpx;
  353. color: #555;
  354. }
  355. }
  356. .box1:nth-last-child(1) {
  357. border: none;
  358. }
  359. .btn {
  360. margin-top: 166rpx;
  361. width: 670rpx;
  362. height: 96rpx;
  363. background-color: #506dff;
  364. border-radius: 50rpx;
  365. box-shadow: 0 4rpx 28rpx 0 rgba(132,123,255,0.4);
  366. font-size: 40rpx;
  367. color: #fff;
  368. text-align: center;
  369. line-height: 96rpx;
  370. // margin: 40rpx 0 36rpx;
  371. }
  372. }
  373. }
  374. </style>