pay.vue 6.7 KB

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