cashierDesk.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <template>
  2. <view>
  3. <view class="goback" v-if="this.show == true">
  4. <view class="gb-bg">
  5. <view class="check">
  6. 确认要离开收银台吗?
  7. </view>
  8. <view class="toast">
  9. 订单已提交成功,超时未支付将会取消订单,请尽快完成支付。
  10. </view>
  11. <view class="but">
  12. <view class="no" @click="no()">
  13. 取消支付
  14. </view>
  15. <view class="yes" @click="yes()">
  16. 继续支付
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="payBlock">
  22. <view class="payMoney">
  23. <text style="font-size: 32rpx;">¥</text>{{payData.payMoney.toFixed(2)}}
  24. </view>
  25. <view class="payToast">需支付</view>
  26. </view>
  27. <view class="payCheck">
  28. <view class="typeBlock border-b" @click="type = 2">
  29. <view class="payCheckTitle">
  30. <image src="../../../static/alipay.png" class="payTypeImage"></image>
  31. <view class="payTitle">支付宝支付</view>
  32. </view>
  33. <image src="../../../static/sel@2x.png" v-if="type === 2" class="checkIcon"></image>
  34. <image src="../../../static/unsel.png" v-else class="checkIcon"></image>
  35. </view>
  36. <view class="typeBlock border-b" @click="type = 1">
  37. <view class="payCheckTitle">
  38. <image src="../../../static/wechat.png" class="payTypeImage"></image>
  39. <view class="payTitle">微信支付</view>
  40. </view>
  41. <image src="../../../static/sel@2x.png" v-if="type === 1" class="checkIcon"></image>
  42. <image src="../../../static/unsel.png" v-else class="checkIcon"></image>
  43. </view>
  44. <view class="typeBlock" @click="type = 3">
  45. <view class="payCheckTitle">
  46. <image src="../../../static/yu‘e@2x.png" class="payTypeImage"></image>
  47. <view class="payTitle">余额支付</view>
  48. <view class="balance">(可用¥{{balance}})</view>
  49. </view>
  50. <image src="../../../static/sel@2x.png" v-if="type === 3" class="checkIcon"></image>
  51. <image src="../../../static/unsel.png" v-else class="checkIcon"></image>
  52. </view>
  53. </view>
  54. <view class="payBtn" @click="toPay()">
  55. {{type==1?'微信':type==2?'支付宝':'余额'}}支付¥{{payData.payMoney.toFixed(2)}}
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. import {
  61. getUserInfo
  62. } from "../../../api/myApi.js"
  63. import {
  64. carwashOrder
  65. } from "@/api/carWash.js"
  66. import {
  67. payOrder
  68. } from '../../../api/maintain.js'
  69. export default {
  70. data() {
  71. return {
  72. show: false,
  73. payData: {},
  74. type: 1,
  75. balance: 0,
  76. orderInfo: '',
  77. page: ''
  78. };
  79. },
  80. onLoad(options) {
  81. this.payData = JSON.parse(options.params)
  82. this.page = options.page
  83. this.getUser()
  84. console.log(this.payData);
  85. },
  86. onBackPress(e) {
  87. if (e.from == 'backbutton') {
  88. this.show = true
  89. return true;
  90. } else if (e.from == 'navigateBack') {
  91. return false;
  92. }
  93. },
  94. methods: {
  95. no() {
  96. uni.showToast({
  97. icon: "none",
  98. title: "顾客取消支付"
  99. })
  100. setTimeout(()=>{
  101. uni.navigateBack({
  102. delta: 1
  103. })
  104. }, 1000)
  105. },
  106. yes() {
  107. this.show = false
  108. },
  109. toPay() {
  110. this.payData.payType = this.type
  111. if (this.payData.payType === 3) {
  112. if (this.payData.payMoney > this.balance) {
  113. return uni.showToast({
  114. icon: "none",
  115. title: "余额不足"
  116. })
  117. }
  118. }
  119. if (this.page === 'carwash') {
  120. this.carWash()
  121. } else if (this.page === 'maintenance') {
  122. this.maintenance()
  123. }
  124. },
  125. getUser() {
  126. getUserInfo().then(res => {
  127. this.balance = res.data.balance
  128. })
  129. },
  130. carWash() {
  131. carwashOrder(this.payData).then(res => {
  132. if (this.payData.payType === 1 || this.payData.payType === 2) {
  133. if (this.payData.payType === 1) {
  134. this.orderInfo = res.data.wechatOrder
  135. } else if (this.payData.payType === 2) {
  136. this.orderInfo = res.data.zfbOrder
  137. }
  138. this.payment()
  139. }
  140. })
  141. },
  142. maintenance() {
  143. payOrder(this.payData).then(res => {
  144. if (this.payData.payType === 1 || this.payData.payType === 2) {
  145. if (this.payData.payType === 1) {
  146. this.orderInfo = res.data.wechatOrder
  147. } else if (this.payData.payType === 2) {
  148. this.orderInfo = res.data.zfbOrder
  149. }
  150. this.payment()
  151. }
  152. })
  153. },
  154. payment() {
  155. let payType = this.payData.payType === 1 ? 'wxpay' : 'alipay'
  156. console.log('订单西悉尼', this.orderInfo);
  157. uni.requestPayment({
  158. provider: payType,
  159. orderInfo: this.orderInfo,
  160. success: (res) => {
  161. console.log('下单支付===============>', res);
  162. if (this.page === 'carwash') {
  163. uni.redirectTo({
  164. url: '/pages/preCarWash/washOrder/index?token=' + uni.getStorageSync(
  165. 'token')
  166. })
  167. } else if (this.page === 'maintenance') {
  168. uni.redirectTo({
  169. url: '/pages/maintenance/maintainOrder/index?token=' + uni
  170. .getStorageSync('token')
  171. })
  172. }
  173. },
  174. fail: (res) => {
  175. console.log(res, '支付失败fail');
  176. uni.showToast({
  177. icon: 'none',
  178. title: '支付失败:' + res.errMsg + ',code:' + res.code + ',errCode:' + res
  179. .errCode
  180. })
  181. }
  182. })
  183. }
  184. }
  185. }
  186. </script>
  187. <style lang="scss">
  188. page {
  189. background-color: #F5F5F5;
  190. }
  191. .goback {
  192. width: 100%;
  193. height: 100%;
  194. background-color: rgba(0, 0, 0, 0.5);
  195. position: fixed;
  196. z-index: 999999999999999999;
  197. top: 0;
  198. .gb-bg {
  199. width: 600rpx;
  200. height: 378rpx;
  201. background: #FFFFFF;
  202. border-radius: 16rpx;
  203. box-sizing: border-box;
  204. padding: 50rpx 70rpx;
  205. margin: 0 auto;
  206. margin-top: 50%;
  207. .check {
  208. height: 29rpx;
  209. font-size: 30rpx;
  210. font-weight: bold;
  211. color: #333333;
  212. line-height: 40rpx;
  213. text-align: center;
  214. }
  215. .toast {
  216. width: 467rpx;
  217. height: 63rpx;
  218. font-size: 26rpx;
  219. font-weight: 500;
  220. color: #333333;
  221. line-height: 36rpx;
  222. margin: 56rpx 0;
  223. }
  224. .but {
  225. display: flex;
  226. justify-content: space-between;
  227. .no {
  228. width: 210rpx;
  229. height: 70rpx;
  230. background: #FFFFFF;
  231. border: 1px solid #0060FF;
  232. border-radius: 35rpx;
  233. font-size: 28rpx;
  234. font-weight: 500;
  235. color: #0062FF;
  236. line-height: 70rpx;
  237. text-align: center;
  238. }
  239. .yes {
  240. width: 210rpx;
  241. height: 70rpx;
  242. background: linear-gradient(0deg, #005AFF 0%, #0078FF 100%);
  243. border-radius: 35rpx;
  244. font-size: 28rpx;
  245. font-weight: 500;
  246. color: #FFFFFF;
  247. line-height: 70rpx;
  248. text-align: center;
  249. }
  250. }
  251. }
  252. }
  253. .payBlock {
  254. width: 100%;
  255. height: 225rpx;
  256. background-color: $uni-text-color-inverse;
  257. display: flex;
  258. flex-direction: column;
  259. align-items: center;
  260. justify-content: center;
  261. border-radius: 0 0 16rpx 16rpx;
  262. margin-bottom: 30rpx;
  263. .payMoney {
  264. font: {
  265. size: 50rpx;
  266. weight: bold;
  267. }
  268. ;
  269. color: $uni-text-color;
  270. }
  271. .payToast {
  272. font: {
  273. size: 24rpx;
  274. weight: 500;
  275. }
  276. ;
  277. color: $uni-text-color-grey;
  278. }
  279. }
  280. .payCheck {
  281. width: calc(100% - 80rpx);
  282. padding: 0 40rpx;
  283. background-color: $uni-text-color-inverse;
  284. border-radius: 16px;
  285. .typeBlock {
  286. width: calc(100% - 10rpx);
  287. height: 125rpx;
  288. padding-left: 10rpx;
  289. display: flex;
  290. align-items: center;
  291. justify-content: space-between;
  292. .payCheckTitle {
  293. height: 100%;
  294. display: flex;
  295. align-items: center;
  296. .payTypeImage {
  297. width: 44rpx;
  298. height: 44rpx;
  299. }
  300. .payTitle {
  301. font: {
  302. size: 30rpx;
  303. weight: 500;
  304. }
  305. ;
  306. color: $uni-text-color;
  307. margin-left: 24rpx;
  308. }
  309. .balance {
  310. font: {
  311. size: 30rpx;
  312. weight: 500;
  313. }
  314. ;
  315. color: $uni-text-color-grey;
  316. margin-left: 17rpx;
  317. }
  318. }
  319. .checkIcon {
  320. width: 36rpx;
  321. height: 36rpx;
  322. }
  323. }
  324. .border-b {
  325. border-bottom: 1px solid #EEEEEE;
  326. }
  327. }
  328. .payBtn {
  329. width: 600rpx;
  330. height: 90rpx;
  331. text-align: center;
  332. line-height: 90rpx;
  333. background: linear-gradient(0deg, #0078FF 0%, #005AFF 100%);
  334. font: {
  335. size: 32rpx;
  336. weight: 500;
  337. }
  338. ;
  339. color: $uni-text-color-inverse;
  340. border-radius: 45rpx;
  341. margin: 174rpx auto;
  342. }
  343. </style>