index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <template>
  2. <view :data-theme="theme">
  3. <view class='wrapper'>
  4. <view class='item borRadius14'>
  5. <view class="title">¥<text>{{payPrice}}</text></view>
  6. <view class='list'>
  7. <block v-for="(item,index) in cartArr" :key='index'>
  8. <view v-if="item.payStatus === 1" class='payItem acea-row row-middle'
  9. :class='active==index ?"on":""' @tap='payItem(index,item)'>
  10. <view class='name acea-row row-center-wrapper'>
  11. <view class='iconfont animated'
  12. :class='(item.icon) + " " + (animated==true&&active==index ?"bounceIn":"")'>
  13. </view>
  14. {{item.name}}
  15. </view>
  16. <view class="acea-row">
  17. <view class='tip'>
  18. {{item.title}}
  19. <block v-if="item.value === 'yue'">
  20. {{item.userBalance}}
  21. </block>
  22. </view>
  23. <view class="radio">
  24. <block v-if="active==index">
  25. <view class="iconfont icon-xuanzhong1 font-color"></view>
  26. </block>
  27. <block v-else>
  28. <view class="iconfont icon-weixuanzhong"></view>
  29. </block>
  30. </view>
  31. </view>
  32. </view>
  33. </block>
  34. </view>
  35. </view>
  36. </view>
  37. <view v-if="isShow" class="titleNo">暂无支付方式!</view>
  38. <view class="btn-box">
  39. <button class='Bnt bg-color' @tap='getOrderPay' :disabled="isBuy">立即支付</button>
  40. </view>
  41. <view class="alipaysubmit" v-html="formContent"></view>
  42. </view>
  43. </template>
  44. <script>
  45. // +----------------------------------------------------------------------
  46. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  47. // +----------------------------------------------------------------------
  48. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  49. // +----------------------------------------------------------------------
  50. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  51. // +----------------------------------------------------------------------
  52. // | Author: CRMEB Team <admin@crmeb.com>
  53. // +----------------------------------------------------------------------
  54. import {
  55. orderPayApi,
  56. wechatQueryPayResult
  57. } from '@/api/order.js';
  58. import {
  59. svipOrderCreateApi
  60. } from '@/api/activity.js';
  61. import {
  62. openOrderSubscribe
  63. } from '@/utils/SubscribeMessage.js';
  64. import {
  65. Debounce
  66. } from '@/utils/validate.js'
  67. import {
  68. mapGetters
  69. } from "vuex";
  70. import store from '@/store'
  71. import orderPay from "@/mixins/OrderPay.js";
  72. let app = getApp();
  73. export default {
  74. mixins: [orderPay],
  75. data() {
  76. return {
  77. active: null, //支付方式切换
  78. theme: app.globalData.theme,
  79. //支付方式
  80. cartArr: [],
  81. payPrice: '',
  82. orderNo: '',
  83. animated: false,
  84. payType: '', //支付方式
  85. payChannel: '',
  86. formContent: '',
  87. isShow: false,
  88. userBalance: '', //余额
  89. fromType: '' ,//页面来源,svip支付,购买商品
  90. //isBuy: false //是否可以点击购买
  91. }
  92. },
  93. computed: {
  94. ...mapGetters(['productType', 'systemPlatform'])
  95. },
  96. onLoad(options) {
  97. this.payPrice = options.payPrice;
  98. this.orderNo = options.orderNo;
  99. this.fromType = options.fromType || ''
  100. },
  101. mounted() {
  102. this.payConfig();
  103. },
  104. methods: {
  105. // 支付配置
  106. payConfig() {
  107. uni.hideLoading();
  108. // 支付方式
  109. store.dispatch('getPayConfig').then((res) => {
  110. this.cartArr = res.payConfig;
  111. this.userBalance = res.userBalance;
  112. // if(this.fromType === 'svip') this.cartArr[1].payStatus = 0
  113. if (this.cartArr.length) {
  114. this.active = 0;
  115. this.payType = this.cartArr[0].value;
  116. this.isShow = false;
  117. } else {
  118. this.isShow = true;
  119. return this.$util.Tips({
  120. title: '暂无支付方式!'
  121. })
  122. }
  123. });
  124. },
  125. payItem: Debounce(function(e,item) {
  126. let that = this;
  127. if(item.userBalance) that.userBalance = item.userBalance
  128. let active = e;
  129. that.active = active;
  130. that.animated = true;
  131. that.payType = that.cartArr[active].value;
  132. setTimeout(function() {
  133. that.car();
  134. }, 500);
  135. }),
  136. car: function() {
  137. let that = this;
  138. that.animated = false;
  139. },
  140. //选择支付方式的判断,传参
  141. getPayCheck() {
  142. if (!this.payType) return this.$util.Tips({
  143. title: '请选择支付方式'
  144. });
  145. if (this.payType === 'yue') {
  146. this.payChannel = 'yue'
  147. } else if (this.payType == 'alipay') {
  148. // #ifdef H5
  149. this.payChannel = 'alipay';
  150. // #endif
  151. // #ifdef APP-PLUS
  152. this.payChannel = 'alipayApp';
  153. // #endif
  154. } else {
  155. // #ifdef H5
  156. this.payChannel = this.$wechat.isWeixin() ? 'public' : 'h5';
  157. // #endif
  158. // #ifdef APP-PLUS
  159. this.payChannel = this.systemPlatform === 'ios' ? 'wechatIos' : 'wechatAndroid';
  160. // #endif
  161. // #ifdef MP
  162. this.payChannel = "mini";
  163. if (this.productType == 'video') {
  164. this.payChannel = "video";
  165. } else {
  166. this.payChannel = "mini";
  167. }
  168. // #endif
  169. }
  170. },
  171. //立即支付
  172. getOrderPay: Debounce(function() {
  173. this.getPayCheck();
  174. if (Number(this.payPrice)>Number(this.userBalance) && this.payType === 'yue') return this.$util.Tips({
  175. title: '余额的金额不够,请切换支付方式'
  176. });
  177. uni.showLoading({
  178. title: '加载中...'
  179. });
  180. this.isBuy = true;
  181. if (this.fromType === 'svip') {
  182. svipOrderCreateApi({
  183. cardId: this.orderNo,
  184. payChannel: this.payChannel,
  185. payType: this.payType,
  186. }).then(res => {
  187. this.handleOrderPay(res, res.data.orderNo, this.productType, this.fromType, this
  188. .payType, this.payPrice)
  189. }).catch(err => {
  190. uni.hideLoading();
  191. this.isBuy = false;
  192. return this.$util.Tips({
  193. title: err
  194. });
  195. });
  196. } else {
  197. // 订单支付
  198. // if (this.fromType == 'fast') {
  199. // this.changeOrderExpressPay(this.orderNo, this.payChannel, this.payType ,this.productType, this.fromType, this.payPrice)
  200. // } else {
  201. this.changeOrderPay(this.orderNo, this.payChannel, this.payType ,this.productType, this.fromType, this.payPrice)
  202. // }
  203. // orderPayApi({
  204. // orderNo: this.orderNo,
  205. // payChannel: this.payChannel,
  206. // payType: this.payType,
  207. // scene: this.productType === 'normal' ? 0 : 1177
  208. // }).then(res => {
  209. // this.handleOrderPay(res, this.orderNo, this.productType, this.fromType, this
  210. // .payType, this.payPrice)
  211. // }).catch(err => {
  212. // uni.hideLoading();
  213. // this.isBuy = false;
  214. // return this.$util.Tips({
  215. // title: err
  216. // });
  217. // });
  218. }
  219. })
  220. },
  221. }
  222. </script>
  223. <style lang="scss" scoped>
  224. .titleNo {
  225. width: 100%;
  226. font-size: 28rpx;
  227. text-align: center;
  228. }
  229. .btn-box {
  230. padding: 0 30rpx;
  231. position: fixed;
  232. bottom: 43rpx;
  233. }
  234. .Bnt {
  235. font-size: 30rpx;
  236. font-weight: bold;
  237. color: #fff;
  238. width: 690rpx;
  239. height: 86rpx;
  240. border-radius: 43rpx;
  241. text-align: center;
  242. line-height: 86rpx;
  243. }
  244. .wrapper {
  245. padding: 30rpx;
  246. .list {
  247. margin-top: 50rpx;
  248. }
  249. .item {
  250. padding: 50rpx 30rpx;
  251. font-size: 30rpx;
  252. color: #333333;
  253. background-color: #fff;
  254. .title {
  255. text-align: center;
  256. @include main_color(theme);
  257. font-size: 34rpx;
  258. text {
  259. font-weight: 800;
  260. font-size: 50rpx;
  261. }
  262. }
  263. }
  264. .payItem {
  265. border-bottom: 1px solid #eee;
  266. justify-content: space-between;
  267. height: 138rpx;
  268. line-height: 138rpx;
  269. width: 100%;
  270. box-sizing: border-box;
  271. font-size: 32pxrpx;
  272. color: #333333;
  273. .on {
  274. // border-color: #fc5445;
  275. @include coupons_border_color(theme);
  276. color: $theme-color;
  277. }
  278. .name {
  279. .iconfont {
  280. width: 48rpx;
  281. height: 48rpx;
  282. border-radius: 50%;
  283. text-align: center;
  284. line-height: 48rpx;
  285. background-color: #fe960f;
  286. color: #fff;
  287. font-size: 30rpx;
  288. margin-right: 28rpx;
  289. }
  290. }
  291. .iconfont.icon-weixinzhifu1 {
  292. background-color: #41b035;
  293. }
  294. .iconfont.icon-zhifubao {
  295. background-color: #00AAEA;
  296. }
  297. .tip {
  298. text-align: center;
  299. font-size: 26rpx;
  300. color: #aaa;
  301. margin-right: 20rpx;
  302. }
  303. .radio {
  304. .iconfont {
  305. font-size: 46rpx;
  306. }
  307. }
  308. }
  309. }
  310. </style>