myvip.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. <template>
  2. <view class="content">
  3. <view class="list">
  4. <view @click="actionIndex=index" class="list-box" v-for="(item,index) in list" :key='index'
  5. :class="{'action':actionIndex==index}">
  6. <view class="list-foot">
  7. <view class="list-pir">
  8. ¥{{item.pir}}
  9. </view>
  10. </view>
  11. <view class="list-level">
  12. {{item.level}}
  13. </view>
  14. </view>
  15. </view>
  16. <view class="top">
  17. <view class="top-sub">
  18. 申请加盟立享特权
  19. </view>
  20. </view>
  21. <view class="app margin-t-30">
  22. <view class="pay-type-list">
  23. <!-- v-if="ispg == 'android'" -->
  24. <!-- #ifdef APP-PLUS -->
  25. <!-- <view class="type-item b-b" @click="type = 'wechat'">
  26. <text class="icon iconfont iconweixin"></text>
  27. <view class="con">
  28. <text class="tit">微信支付</text>
  29. <text>推荐使用微信支付</text>
  30. </view>
  31. <label class="radio">
  32. <radio value="" color="#5dbc7c" :checked="type == 'wechat'"></radio>
  33. </label>
  34. </view> -->
  35. <view class="type-item b-b" @click="type = 'ali'">
  36. <text class="icon iconfont iconzhifubao"></text>
  37. <view class="con"><text class="tit">支付宝支付</text></view>
  38. <label class="radio">
  39. <radio value="" color="#5dbc7c" :checked="type == 'ali'"></radio>
  40. </label>
  41. </view>
  42. <!-- #endif -->
  43. <view class="type-item" @click="type = 'yue'">
  44. <text class="icon iconfont iconyue"></text>
  45. <view class="con">
  46. <text class="tit">余额支付</text>
  47. <text>可用余额 ¥{{ now_money }}</text>
  48. </view>
  49. <label class="radio">
  50. <radio value="" color="#5dbc7c" :checked="type == 'yue'"></radio>
  51. </label>
  52. </view>
  53. </view>
  54. </view>
  55. <view class="box-content" v-if="actionIndex==1">
  56. <view class="content-title">
  57. <view class="title">
  58. 加盟即送:{{partner.name}}
  59. </view>
  60. </view>
  61. <view class="img">
  62. <image :src="partner.uri" mode=""></image>
  63. </view>
  64. </view>
  65. <view class="footer">
  66. <view class="price-content">
  67. <text>{{list[actionIndex].level}}</text>
  68. <text class="price-tip">¥</text>
  69. <text class="price">{{ list[actionIndex].pir }}</text>
  70. </view>
  71. <text class="submit" :class="{ submitNo: !payType }" @click="payType ? submit() : ''">提交订单</text>
  72. </view>
  73. </view>
  74. </template>
  75. <script>
  76. import {
  77. vipList,
  78. vipCompany,
  79. vipPartner
  80. } from '@/api/user.js';
  81. import { balance } from '@/api/wallet.js';
  82. export default {
  83. data() {
  84. return {
  85. actionIndex: 0,
  86. type: 'yue',
  87. now_money: 0,
  88. payType: true,
  89. list: [{
  90. src: '../../static/img/le1.png',
  91. level: '分公司',
  92. pir: 0,
  93. },
  94. {
  95. src: '../../static/img/le1.png',
  96. level: '分销商',
  97. pir: 0,
  98. },
  99. ],
  100. // 赠送商品
  101. partner:{}
  102. }
  103. },
  104. onLoad() {
  105. this.vipList();
  106. this.getBalance();
  107. },
  108. methods: {
  109. // 获取vipList
  110. vipList() {
  111. const list = this.list
  112. vipList().then((e) => {
  113. list[0].pir = e.data.company;
  114. list[1].pir = e.data.partner;
  115. this.partner = e.data.partner_gift;
  116. }).catch((e) => {
  117. console.log(e);
  118. })
  119. },
  120. getBalance(){
  121. // 载入余额
  122. balance({}).then(({
  123. data
  124. }) => {
  125. // 获取余额
  126. this.now_money = data.now_money;
  127. });
  128. },
  129. // 支付回调
  130. payChecked(data){
  131. console.log(data,'fanhui ');
  132. console.log(this.type);
  133. console.log(data.payConfig,'payConfig ');
  134. const that = this;
  135. // #ifdef APP-PLUS
  136. if (that.type == 'ali') {
  137. const url = data.data.payConfig;
  138. console.log(url, 'url');
  139. uni.requestPayment({
  140. provider: 'alipay',
  141. orderInfo: url,
  142. success: res => {
  143. console.log(res);
  144. uni.showToast({
  145. title: '支付成功',
  146. duration: 2000
  147. });
  148. obj.paySuccessTo();
  149. },
  150. fail: e => {
  151. console.log(e);
  152. },
  153. complete: () => {}
  154. });
  155. obj.payLoding = false;
  156. return
  157. }
  158. // #endif
  159. if (that.type == 'yue') {
  160. that.paySuccess();
  161. that.getBalance()
  162. }
  163. },
  164. // 支付成功
  165. paySuccess(){
  166. const that = this;
  167. uni.showModal({
  168. title: '恭喜',
  169. content: '成功开通'+that.list[that.actionIndex].level,
  170. showCancel: false,
  171. });
  172. that.payType = true;
  173. },
  174. // 提交订单
  175. submit() {
  176. const that = this;
  177. if (!that.payType) {
  178. return
  179. }
  180. that.payType = false;
  181. if (that.actionIndex == 0) {
  182. vipCompany({
  183. pay_type: that.type
  184. }).then((data) => {
  185. that.payChecked(data)
  186. }).catch(() => {
  187. that.payType = true;
  188. })
  189. }
  190. if (that.actionIndex == 1) {
  191. vipPartner({
  192. pay_type: that.type
  193. }).then((data) => {
  194. that.payChecked(data)
  195. }).catch(() => {
  196. that.payType = true;
  197. })
  198. }
  199. }
  200. }
  201. }
  202. </script>
  203. <style lang="scss">
  204. .box-content {
  205. margin-bottom: 50rpx;
  206. background-color: rgb(15, 15, 15);
  207. overflow: hidden;
  208. .img {
  209. width: 750rpx;
  210. height: 750rpx;
  211. image {
  212. width: 100%;
  213. height: 100%;
  214. }
  215. }
  216. .content-title {
  217. padding: 30rpx 20rpx;
  218. border-bottom-left-radius: 10rpx;
  219. border-bottom-right-radius: 10rpx;
  220. background-color: rgb(29, 28, 33);
  221. .title {
  222. font-size: 39rpx;
  223. font-weight: bold;
  224. color: #FFFFFF;
  225. margin-bottom: 20rpx;
  226. }
  227. .text {
  228. margin: 10rpx 0;
  229. color: #FFFFFF;
  230. font-size: 28rpx;
  231. }
  232. }
  233. }
  234. .pay-type-list {
  235. margin-top: 20upx;
  236. background-color: #fff;
  237. padding-left: 60upx;
  238. .type-item {
  239. height: 120upx;
  240. padding: 20upx 0;
  241. display: flex;
  242. justify-content: space-between;
  243. align-items: center;
  244. padding-right: 60upx;
  245. font-size: 30upx;
  246. position: relative;
  247. }
  248. .icon {
  249. width: 100upx;
  250. font-size: 52upx;
  251. }
  252. .iconyue {
  253. color: #fe8e2e;
  254. }
  255. .iconweixin {
  256. color: #36cb59;
  257. }
  258. .iconzhifubao {
  259. color: #01aaef;
  260. }
  261. .tit {
  262. font-size: $font-lg;
  263. color: $font-color-dark;
  264. margin-bottom: 4upx;
  265. }
  266. .con {
  267. flex: 1;
  268. display: flex;
  269. flex-direction: column;
  270. font-size: $font-sm;
  271. color: $font-color-light;
  272. }
  273. }
  274. .content {
  275. line-height: 1;
  276. padding-top: 50rpx;
  277. padding-bottom: 50px;
  278. .top {
  279. padding-top: 40rpx;
  280. position: relative;
  281. .top-sub {
  282. width: 377rpx;
  283. margin: 0 auto;
  284. height: 65rpx;
  285. background: #554637;
  286. border-radius: 33rpx;
  287. font-size: 30rpx;
  288. font-weight: 500;
  289. color: #E2D29F;
  290. display: flex;
  291. align-items: center;
  292. justify-content: center;
  293. // margin:0rpx auto;
  294. }
  295. }
  296. .center {
  297. text-align: center;
  298. margin: 40rpx 0;
  299. .center-img {
  300. width: 331rpx;
  301. height: 31rpx;
  302. }
  303. }
  304. .list {
  305. padding-left: 20rpx;
  306. display: flex;
  307. flex-wrap: wrap;
  308. .list-box {
  309. width: 345rpx;
  310. padding-top: 30rpx;
  311. background: #FFFFFF;
  312. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  313. border-radius: 10rpx;
  314. margin-right: 20rpx;
  315. margin-bottom: 20rpx;
  316. &.action {
  317. border: 2px solid #E2D29F;
  318. ;
  319. }
  320. .list-level {
  321. padding-left: 20rpx;
  322. font-size: 36rpx;
  323. font-weight: bold;
  324. color: #554637;
  325. line-height: 70rpx;
  326. text-align: center;
  327. padding-bottom: 30rpx;
  328. }
  329. .list-foot {
  330. text-align: center;
  331. padding: 0 20rpx;
  332. font-size: 50rpx;
  333. color: #E2D29F;
  334. font-weight: bold;
  335. padding: 30rpx 0;
  336. }
  337. }
  338. }
  339. }
  340. .footer {
  341. position: fixed;
  342. left: 0;
  343. bottom: 0;
  344. z-index: 995;
  345. display: flex;
  346. align-items: center;
  347. width: 100%;
  348. height: 90rpx;
  349. justify-content: space-between;
  350. font-size: 30rpx;
  351. background-color: #fff;
  352. z-index: 998;
  353. color: $font-color-base;
  354. box-shadow: 0 -1px 5px rgba(0, 0, 0, 0.1);
  355. .price-content {
  356. padding-left: 30rpx;
  357. }
  358. .price-tip {
  359. color: $font-color-base;
  360. margin-left: 8rpx;
  361. }
  362. .price {
  363. font-size: 36rpx;
  364. color: $font-color-base;
  365. }
  366. .submit {
  367. display: flex;
  368. align-items: center;
  369. justify-content: center;
  370. width: 280rpx;
  371. height: 100%;
  372. color: #9F570E;
  373. font-size: 32rpx;
  374. background: $bgBaseBg;
  375. &.submitNo {
  376. background-color: $font-color-disabled;
  377. }
  378. }
  379. }
  380. </style>