pay.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <view class="">
  3. <u-navbar
  4. title="收银台"
  5. @leftClick="leftClick"
  6. :autoBack="false"
  7. :safeAreaInsetTop="true"
  8. >
  9. </u-navbar>
  10. <view class="page-wrap">
  11. <view class="pay-way page-wrap">
  12. <u-radio-group v-model="params.paymentMode" placement="column" @change="groupChange">
  13. <!-- <view class="pay-way-item u-flex u-row-between">
  14. <view class="left">微信支付</view>
  15. <u-radio :name="1" activeColor="#00A447" size="36rpx"></u-radio>
  16. </view> -->
  17. <view :class="{disabled:customBalance<params.payAmount}" class="pay-way-item u-flex u-row-between">
  18. <view class="left">旭烁余额支付(¥ {{customBalance}})</view>
  19. <u-radio :name="2" :disabled="customBalance<params.payAmount" activeColor="#00A447" size="36rpx"></u-radio>
  20. </view>
  21. <!-- <view class="pay-way-item u-flex u-row-between">
  22. <view class="left">积分支付(¥ {{credit}})</view>
  23. <u-radio :name="3" :disabled="fromPage!=creditOrder&&customBalance<params.payAmount" activeColor="#00A447" size="36rpx"></u-radio>
  24. </view> -->
  25. <view class="pay-way-item u-flex u-row-between">
  26. <view class="left">农商行支付</view>
  27. <u-radio :name="4" activeColor="#00A447" size="36rpx"></u-radio>
  28. </view>
  29. </u-radio-group>
  30. </view>
  31. <view class="full-btn" @click="payRoute">去支付<text>¥ {{params.payAmount}}</text></view>
  32. <u-popup :show="checkPassShow" @close="checkPassClose" mode="center">
  33. <view class="check-pass">
  34. <view class="title">请输入支付密码</view>
  35. <view class="name">旭烁商城</view>
  36. <view class="number">¥{{params.payAmount}}</view>
  37. <view class="the-way u-flex u-row-between">
  38. <view class="left">支付方式</view>
  39. <view class="right u-flex">
  40. <u--image class="image" :src="staticUrl+'/img/qian.png'" width="32rpx" height="32rpx"></u--image>
  41. <text style="margin-left: 10px;">零钱</text>
  42. </view>
  43. </view>
  44. <u-code-input v-model="paypass"
  45. :space="0"
  46. :size="40"
  47. @finish="checkPayPassword"
  48. :maxlength="6"
  49. :adjustPosition="true"
  50. :dot="true"
  51. :focus="true"
  52. :disabled-keyboard="false" >
  53. </u-code-input>
  54. <!-- <view class="btn-wrap u-flex">
  55. <u-button text="取消" @click="checkPassShow=false"></u-button>
  56. <u-button text="确认" @click="checkPassShow=false"></u-button>
  57. </view> -->
  58. </view>
  59. </u-popup>
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. export default {
  65. data() {
  66. return {
  67. staticUrl:this.$commonConfig.staticUrl,
  68. fromPage:'',
  69. customBalance:'',
  70. credit:'',
  71. params:{
  72. paymentMode:null,
  73. orderId:'',
  74. openid:'',
  75. payAmount:'',
  76. payResult:{},
  77. },
  78. checkPassShow:false,
  79. paypass:'',
  80. }
  81. },
  82. onShow() {
  83. this.getMemberInfo();
  84. },
  85. onLoad(page) {
  86. console.log('page',page);
  87. this.fromPage = page.fromPage;
  88. this.params.orderId = page.orderId;
  89. this.params.openid = this.vuex_wechatOpenid;
  90. this.params.payAmount = page.payAmount;
  91. this.params.paymentMode = page.paymentMode || 4;
  92. },
  93. methods: {
  94. leftClick(){
  95. uni.showModal({
  96. title: '提示',
  97. content: '是否放弃本次付款!',
  98. success: res => {
  99. if (res.confirm) {
  100. uni.navigateBack()
  101. } else if (res.cancel) {
  102. console.log('用户点击取消');
  103. }
  104. }
  105. });
  106. },
  107. getMemberInfo(){
  108. this.$u.api.memberInfo({id:this.vuex_user_info.userid}).then(res=>{
  109. this.customBalance= res.data.balance;
  110. this.credit= res.data.credit;
  111. }).catch(err=>{
  112. console.log('memberInfo',err.data);
  113. })
  114. },
  115. checkPassClose(){
  116. this.checkPassShow = false
  117. },
  118. payRoute(){
  119. if(this.params.paymentMode==2){
  120. this.checkPassShow = true
  121. }else{
  122. this.gotoPay();
  123. }
  124. },
  125. checkPayPassword(){
  126. this.$u.api.checkPayPassword({payPassword:this.paypass}).then(res=>{
  127. // console.log('res',res.data);
  128. if(res.data==1){//密码正确
  129. this.gotoPay()
  130. }else{
  131. this.paypass = '';
  132. uni.showToast({
  133. title:'密码错误',
  134. icon:'error'
  135. });
  136. }
  137. }).catch(err=>{
  138. this.paypass = '';
  139. uni.showToast({
  140. title:'密码错误',
  141. icon:'error'
  142. });
  143. console.log('checkPayPassword',err);
  144. })
  145. },
  146. gotoPay(){
  147. console.log('gotoPay',this.params);
  148. this.$u.api.gotoPay(this.params).then(res=>{
  149. this.payResult = res.data.payResult;
  150. if(this.params.paymentMode==1||this.params.paymentMode==4){
  151. this.wxPay()
  152. }else{
  153. uni.$u.route('/shopping/paysuccess');
  154. }
  155. console.log('gotoPayres',res.data);
  156. }).catch(err=>{
  157. this.paypass = '';
  158. this.checkPassShow = false;
  159. console.log('gotoPay',err);
  160. })
  161. },
  162. wxPay(){
  163. uni.requestPayment({
  164. ... this.payResult,
  165. "provider": "wxpay",
  166. "orderInfo": {
  167. // "appid": "wx499********7c70e", // 微信开放平台 - 应用 - AppId,注意和微信小程序、公众号 AppId 可能不一致
  168. // "noncestr": "c5sEwbaNPiXAF3iv", // 随机字符串
  169. // "package": "Sign=WXPay", // 固定值
  170. // "partnerid": "148*****52", // 微信支付商户号
  171. // "prepayid": "wx202254********************fbe90000", // 统一下单订单号
  172. // "timestamp": 1597935292, // 时间戳(单位:秒)
  173. // "sign": "A842B45937F6EFF60DEC7A2EAA52D5A0" // 签名,这里用的 MD5/RSA 签名
  174. },
  175. success(res) {
  176. uni.$u.route('/shopping/paysuccess');
  177. },
  178. fail(e) {
  179. console.log('wxPayfail',e);
  180. }
  181. })
  182. },
  183. groupChange(e){
  184. console.log('groupChange',e);
  185. }
  186. }
  187. }
  188. </script>
  189. <style>
  190. page{
  191. background-color: #F5F5F5;
  192. }
  193. </style>
  194. <style lang="scss" scoped>
  195. .pay-way{
  196. background-color: #fff;
  197. border-radius: 8rpx;
  198. .pay-way-item {
  199. padding: 30rpx;
  200. &:not(:last-child){
  201. border-bottom: 0.5px solid #eee;
  202. }
  203. &.disabled{
  204. .left{
  205. color: #D8D8D8;
  206. }
  207. }
  208. }
  209. .left{
  210. font-size: 30rpx;
  211. font-weight: 500;
  212. color: #333333;
  213. line-height: 42rpx;
  214. }
  215. }
  216. .full-btn{
  217. margin-top: 100rpx;
  218. }
  219. /deep/ .u-popup__content{
  220. overflow: hidden;
  221. border-radius: 8rpx;
  222. }
  223. .check-pass{
  224. padding: 24rpx 40rpx 40rpx;
  225. .title{
  226. margin-bottom: 30rpx;
  227. font-size: 36rpx;
  228. font-weight: 600;
  229. color: #333333;
  230. line-height: 50rpx;
  231. text-align: center;
  232. }
  233. .name{
  234. text-align: center;
  235. font-size: 30rpx;
  236. font-weight: 400;
  237. color: #666666;
  238. line-height: 42rpx;
  239. margin-bottom: 10rpx;
  240. }
  241. .number{
  242. text-align: center;
  243. font-size: 58rpx;
  244. font-weight: 600;
  245. color: #FF3538;
  246. line-height: 81rpx;
  247. margin-bottom: 30rpx;
  248. }
  249. .the-way{
  250. font-size: 30rpx;
  251. font-weight: 400;
  252. color: #333333;
  253. line-height: 42rpx;
  254. margin-bottom: 25rpx;
  255. }
  256. .btn-wrap{
  257. }
  258. }
  259. </style>