index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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. this.changeOrderPay(this.orderNo, this.payChannel, this.payType ,this.productType, this.fromType, this.payPrice)
  199. // orderPayApi({
  200. // orderNo: this.orderNo,
  201. // payChannel: this.payChannel,
  202. // payType: this.payType,
  203. // scene: this.productType === 'normal' ? 0 : 1177
  204. // }).then(res => {
  205. // this.handleOrderPay(res, this.orderNo, this.productType, this.fromType, this
  206. // .payType, this.payPrice)
  207. // }).catch(err => {
  208. // uni.hideLoading();
  209. // this.isBuy = false;
  210. // return this.$util.Tips({
  211. // title: err
  212. // });
  213. // });
  214. }
  215. })
  216. },
  217. }
  218. </script>
  219. <style lang="scss" scoped>
  220. .titleNo {
  221. width: 100%;
  222. font-size: 28rpx;
  223. text-align: center;
  224. }
  225. .btn-box {
  226. padding: 0 30rpx;
  227. position: fixed;
  228. bottom: 43rpx;
  229. }
  230. .Bnt {
  231. font-size: 30rpx;
  232. font-weight: bold;
  233. color: #fff;
  234. width: 690rpx;
  235. height: 86rpx;
  236. border-radius: 43rpx;
  237. text-align: center;
  238. line-height: 86rpx;
  239. }
  240. .wrapper {
  241. padding: 30rpx;
  242. .list {
  243. margin-top: 50rpx;
  244. }
  245. .item {
  246. padding: 50rpx 30rpx;
  247. font-size: 30rpx;
  248. color: #333333;
  249. background-color: #fff;
  250. .title {
  251. text-align: center;
  252. @include main_color(theme);
  253. font-size: 34rpx;
  254. text {
  255. font-weight: 800;
  256. font-size: 50rpx;
  257. }
  258. }
  259. }
  260. .payItem {
  261. border-bottom: 1px solid #eee;
  262. justify-content: space-between;
  263. height: 138rpx;
  264. line-height: 138rpx;
  265. width: 100%;
  266. box-sizing: border-box;
  267. font-size: 32pxrpx;
  268. color: #333333;
  269. .on {
  270. // border-color: #fc5445;
  271. @include coupons_border_color(theme);
  272. color: $theme-color;
  273. }
  274. .name {
  275. .iconfont {
  276. width: 48rpx;
  277. height: 48rpx;
  278. border-radius: 50%;
  279. text-align: center;
  280. line-height: 48rpx;
  281. background-color: #fe960f;
  282. color: #fff;
  283. font-size: 30rpx;
  284. margin-right: 28rpx;
  285. }
  286. }
  287. .iconfont.icon-weixinzhifu1 {
  288. background-color: #41b035;
  289. }
  290. .iconfont.icon-zhifubao {
  291. background-color: #00AAEA;
  292. }
  293. .tip {
  294. text-align: center;
  295. font-size: 26rpx;
  296. color: #aaa;
  297. margin-right: 20rpx;
  298. }
  299. .radio {
  300. .iconfont {
  301. font-size: 46rpx;
  302. }
  303. }
  304. }
  305. }
  306. </style>