myvip.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  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="footer">
  56. <view class="price-content">
  57. <text>{{list[actionIndex].level}}</text>
  58. <text class="price-tip">¥</text>
  59. <text class="price">{{ list[actionIndex].pir }}</text>
  60. </view>
  61. <text class="submit" :class="{ submitNo: !payType }" @click="payType ? submit() : ''">提交订单</text>
  62. </view>
  63. </view>
  64. </template>
  65. <script>
  66. import {
  67. vipList,
  68. vipCompany,
  69. vipPartner
  70. } from '@/api/user.js';
  71. import { balance } from '@/api/wallet.js';
  72. export default {
  73. data() {
  74. return {
  75. actionIndex: 0,
  76. type: 'yue',
  77. now_money: 0,
  78. payType: true,
  79. list: [{
  80. src: '../../static/img/le1.png',
  81. level: '分公司',
  82. pir: 2000,
  83. },
  84. {
  85. src: '../../static/img/le1.png',
  86. level: '分销商',
  87. pir: 2000,
  88. },
  89. ],
  90. }
  91. },
  92. onLoad() {
  93. this.vipList();
  94. this.getBalance();
  95. },
  96. methods: {
  97. // 获取vipList
  98. vipList() {
  99. const list = this.list
  100. vipList().then((e) => {
  101. list[0].pir = e.data.company;
  102. list[1].pir = e.data.partner;
  103. }).catch((e) => {
  104. console.log(e);
  105. })
  106. },
  107. getBalance(){
  108. // 载入余额
  109. balance({}).then(({
  110. data
  111. }) => {
  112. // 获取余额
  113. this.now_money = data.now_money;
  114. });
  115. },
  116. // 支付回调
  117. payChecked(data){
  118. console.log(data,'fanhui ');
  119. const that = this;
  120. if (that.type == 'ali') {
  121. const url = data.payConfig;
  122. console.log(url, 'url');
  123. uni.requestPayment({
  124. provider: 'alipay',
  125. orderInfo: url,
  126. success: res => {
  127. console.log(res);
  128. uni.showToast({
  129. title: '支付成功',
  130. duration: 2000
  131. });
  132. obj.paySuccessTo();
  133. },
  134. fail: e => {
  135. console.log(e);
  136. },
  137. complete: () => {}
  138. });
  139. obj.payLoding = false;
  140. return
  141. }
  142. if (that.type == 'yue') {
  143. that.paySuccess();
  144. that.getBalance()
  145. }
  146. },
  147. // 支付成功
  148. paySuccess(){
  149. const that = this;
  150. uni.showModal({
  151. title: '恭喜',
  152. content: '成功开通'+that.list[that.actionIndex].level,
  153. showCancel: false,
  154. });
  155. that.payType = true;
  156. },
  157. // 提交订单
  158. submit() {
  159. const that = this;
  160. if (!that.payType) {
  161. return
  162. }
  163. that.payType = false;
  164. if (that.actionIndex == 0) {
  165. vipCompany({
  166. pay_type: that.type
  167. }).then((data) => {
  168. that.payChecked(data)
  169. }).catch(() => {
  170. that.payType = true;
  171. })
  172. }
  173. if (that.actionIndex == 1) {
  174. vipPartner({
  175. pay_type: that.type
  176. }).then((data) => {
  177. that.payChecked(data)
  178. }).catch(() => {
  179. that.payType = true;
  180. })
  181. }
  182. }
  183. }
  184. }
  185. </script>
  186. <style lang="scss">
  187. .pay-type-list {
  188. margin-top: 20upx;
  189. background-color: #fff;
  190. padding-left: 60upx;
  191. .type-item {
  192. height: 120upx;
  193. padding: 20upx 0;
  194. display: flex;
  195. justify-content: space-between;
  196. align-items: center;
  197. padding-right: 60upx;
  198. font-size: 30upx;
  199. position: relative;
  200. }
  201. .icon {
  202. width: 100upx;
  203. font-size: 52upx;
  204. }
  205. .iconyue {
  206. color: #fe8e2e;
  207. }
  208. .iconweixin {
  209. color: #36cb59;
  210. }
  211. .iconzhifubao {
  212. color: #01aaef;
  213. }
  214. .tit {
  215. font-size: $font-lg;
  216. color: $font-color-dark;
  217. margin-bottom: 4upx;
  218. }
  219. .con {
  220. flex: 1;
  221. display: flex;
  222. flex-direction: column;
  223. font-size: $font-sm;
  224. color: $font-color-light;
  225. }
  226. }
  227. .content {
  228. line-height: 1;
  229. padding-top: 50rpx;
  230. .top {
  231. padding-top: 40rpx;
  232. position: relative;
  233. .top-sub {
  234. width: 377rpx;
  235. margin: 0 auto;
  236. height: 65rpx;
  237. background: #554637;
  238. border-radius: 33rpx;
  239. font-size: 30rpx;
  240. font-weight: 500;
  241. color: #E2D29F;
  242. display: flex;
  243. align-items: center;
  244. justify-content: center;
  245. // margin:0rpx auto;
  246. }
  247. }
  248. .center {
  249. text-align: center;
  250. margin: 40rpx 0;
  251. .center-img {
  252. width: 331rpx;
  253. height: 31rpx;
  254. }
  255. }
  256. .list {
  257. padding-left: 20rpx;
  258. display: flex;
  259. flex-wrap: wrap;
  260. .list-box {
  261. width: 345rpx;
  262. padding-top: 30rpx;
  263. background: #FFFFFF;
  264. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  265. border-radius: 10rpx;
  266. margin-right: 20rpx;
  267. margin-bottom: 20rpx;
  268. &.action {
  269. border: 2px solid #E2D29F;
  270. ;
  271. }
  272. .list-level {
  273. padding-left: 20rpx;
  274. font-size: 36rpx;
  275. font-weight: bold;
  276. color: #554637;
  277. line-height: 70rpx;
  278. text-align: center;
  279. padding-bottom: 30rpx;
  280. }
  281. .list-foot {
  282. text-align: center;
  283. padding: 0 20rpx;
  284. font-size: 50rpx;
  285. color: #E2D29F;
  286. font-weight: bold;
  287. padding: 30rpx 0;
  288. }
  289. }
  290. }
  291. }
  292. .footer {
  293. position: fixed;
  294. left: 0;
  295. bottom: 0;
  296. z-index: 995;
  297. display: flex;
  298. align-items: center;
  299. width: 100%;
  300. height: 90rpx;
  301. justify-content: space-between;
  302. font-size: 30rpx;
  303. background-color: #fff;
  304. z-index: 998;
  305. color: $font-color-base;
  306. box-shadow: 0 -1px 5px rgba(0, 0, 0, 0.1);
  307. .price-content {
  308. padding-left: 30rpx;
  309. }
  310. .price-tip {
  311. color: $font-color-base;
  312. margin-left: 8rpx;
  313. }
  314. .price {
  315. font-size: 36rpx;
  316. color: $font-color-base;
  317. }
  318. .submit {
  319. display: flex;
  320. align-items: center;
  321. justify-content: center;
  322. width: 280rpx;
  323. height: 100%;
  324. color: #fff;
  325. font-size: 32rpx;
  326. background-color: $base-color;
  327. &.submitNo {
  328. background-color: $font-color-disabled;
  329. }
  330. }
  331. }
  332. </style>