index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. <template>
  2. <view class="content">
  3. <u-sticky>
  4. <View class=" tabs">
  5. <u-tabs :list="tabList" :scrollable="false" lineWidth="30" lineColor="#FFE05C" :activeStyle="{
  6. color: '#333333',
  7. fontWeight: 'bold',
  8. transform: 'scale(1.05)'
  9. }" :current="tabIndex" @click="clickTab"></u-tabs>
  10. </View>
  11. </u-sticky>
  12. <!-- 订单列表 -->
  13. <view :style="{'height':windowHeight}">
  14. <swiper :style="{'height':windowHeight}" :current="tabIndex" @change="swiperChange">
  15. <swiper-item class="swiperItem" v-for="(item,index) in tabList" :key="index">
  16. <view>
  17. <mescroll-item ref="MescrollItem" :i="index" :index="tabIndex" :tabs="tabList" :height="windowHeight" @getQueueingMsg="getQueueingMsg" @serialNumber="serialNumber" @openPay="openPay" @openPayAppointment="openPayAppointment">
  18. </mescroll-item>
  19. </view>
  20. </swiper-item>
  21. </swiper>
  22. </view>
  23. <uni-popup ref="serialNumber">
  24. <view class="serial-number">
  25. <view class="text">
  26. <text>您的排队号</text>
  27. </view>
  28. <view class="number">
  29. <text>{{ orderNumberData.schedulingNo }}</text>
  30. </view>
  31. <view v-if="orderNumberData.overNo" class="text1">
  32. <text>已过号,请重新取号</text>
  33. </view>
  34. <view v-else class="text">
  35. <text>前面还有<text class="number">{{ orderNumberData.waitNoNum || 0 }}</text>人在等待</text>
  36. </view>
  37. <view class="text">
  38. <text>随时关注小程序的排队进程,过号作废</text>
  39. </view>
  40. </view>
  41. </uni-popup>
  42. <uni-popup ref="getQueueingMsg">
  43. <view class="serial-number" :style="{width:'400rpx'}">
  44. <view class="text">
  45. <text>店内已排队数: </text>
  46. <text class="number">{{queueingMsgData.alreadyQueuedTotal}}</text>
  47. </view>
  48. <view class="text">
  49. <text>店内待排队数:</text>
  50. <text class="number">{{queueingMsgData.waitQueuedTotal}}</text>
  51. </view>
  52. <view class="text" :style="{color:'red',fontSize:'35rpx'}">
  53. <text>请您尽快到店签到排队</text>
  54. </view>
  55. </view>
  56. </uni-popup>
  57. <uni-popup ref="popup" :catchtouchmove="true" :animation="false" type="bottom">
  58. <view class=" payView">
  59. <view class="flex-row justify-between">
  60. <text class="payType">请选择支付方式</text>
  61. <image class="x" src="/static/common/ox.png" @click="closePayPopup"></image>
  62. </view>
  63. <view class="payTitle">
  64. <text>选择微信支付或余额支付</text>
  65. </view>
  66. <view :style="{'height':'380rpx'}">
  67. <view class="payItem flex-row justify-between" v-if="openType!=2" @click="payItem(1)">
  68. <view class="flex-row">
  69. <u-icon name="/static/me/u701.png" color="#38db38" size="36"></u-icon>
  70. <view class="payName flex-col justify-center">
  71. <text>余额支付</text>
  72. <text class="balance">可以余额¥{{userInfo.balance || 0}}</text>
  73. </view>
  74. </view>
  75. <view class="flex-col justify-center">
  76. <view v-if="curServiceTab === 1" >
  77. <u-icon name="checkmark-circle-fill" color="#38db38" size="25"></u-icon>
  78. </view>
  79. <view v-else>
  80. <u-icon name="/static/order/ud9.png" color="green" size="25"></u-icon>
  81. </view>
  82. </view>
  83. </view>
  84. <view class="payItem flex-row justify-between" @click="payItem(2)">
  85. <view class="flex-row">
  86. <u-icon name="weixin-circle-fill" color="#38db38" size="36"></u-icon>
  87. <view class="payName flex-col justify-center">
  88. <text>微信支付</text>
  89. </view>
  90. </view>
  91. <view class="flex-col justify-center">
  92. <view v-if="curServiceTab === 2" >
  93. <u-icon name="checkmark-circle-fill" color="#38db38" size="25"></u-icon>
  94. </view>
  95. <view v-else>
  96. <u-icon name="/static/order/ud9.png" color="green" size="25"></u-icon>
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. <view class="commitBtn" @click="commonGeneralOrder">
  102. <text>确定</text>
  103. </view>
  104. </view>
  105. </uni-popup>
  106. <uni-popup ref="passwordPopup">
  107. <view class="passwordView flex-col">
  108. <view class="flex-row justify-center">
  109. <text>请输入交易密码</text>
  110. </view>
  111. <view class="h-tab-bar flex-row justify-center">
  112. <u-code-input v-model="password" mode="box" dot></u-code-input>
  113. </view>
  114. <view class="flex-row justify-center">
  115. <view class="h-operate-btn flex-row justify-center" @click="balancePay">
  116. <text>确定</text>
  117. </view>
  118. </view>
  119. </view>
  120. </uni-popup>
  121. </view>
  122. </template>
  123. <script>
  124. import MescrollItem from "./module/mescrollUni-item.vue";
  125. import tabBar from "../../components/tabBar/tabBar";
  126. export default {
  127. components: {
  128. tabBar,
  129. MescrollItem
  130. },
  131. data() {
  132. return {
  133. orderNumberData:{},
  134. num: 0,
  135. title: 'Hello',
  136. tabIndex: 0,
  137. tabBarIndex:3,
  138. currentTab: 0,
  139. currentServiceTab: 'orderTab1',
  140. queueingMsgData:{},
  141. tabList: [{
  142. name: '全部'
  143. }, {
  144. name: '当前订单'
  145. }, {
  146. name: '待付款'
  147. }, {
  148. name: '已完成'
  149. }],
  150. windowHeight: '',
  151. userInfo:{},
  152. curServiceTab:2,
  153. tradeNo:'',
  154. password:'',
  155. openType:0,//开启的支付类型:1一键支付子订单费用,2:支付预约费用
  156. appointmentOrder:{},
  157. requestStatus : false
  158. }
  159. },
  160. onLoad() {
  161. // uni.hideTabBar({
  162. // animation: false
  163. // })
  164. let sysInfo = uni.getSystemInfoSync()
  165. console.log(sysInfo,'2222222222222222222222222')
  166. this.windowHeight = sysInfo.windowHeight - 74 + 'px' //除标题栏栏外的屏幕可用高度
  167. this.$off()
  168. this.$on('orderListIndex',this.listenerIndex)
  169. },
  170. onShow(){
  171. this.userInfo = uni.getStorageSync('userInfo')
  172. if (uni.getStorageSync('orderListIndex')){
  173. this.tabIndex = uni.getStorageSync('orderListIndex')
  174. }
  175. uni.removeStorageSync('orderListIndex');
  176. this.$refs.MescrollItem[this.tabIndex].downCallback()
  177. },
  178. methods: {
  179. serialNumber(order){
  180. this.$api.viewNumber(order.orderId).then(res=>{
  181. this.orderNumberData = res.data.data
  182. })
  183. this.$refs.serialNumber.open()
  184. },
  185. getQueueingMsg(order){
  186. this.$api.queueInfo(order.orderId).then(res=>{
  187. this.queueingMsgData = res.data.data
  188. })
  189. this.$refs.getQueueingMsg.open()
  190. },
  191. openPayAppointment(order,number){
  192. console.log(order)
  193. console.log(number)
  194. this.appointmentOrder = order
  195. this.openType=number
  196. this.$refs.popup.open()
  197. },
  198. //微信支付预约费用
  199. wechatPay(){
  200. let that = this;
  201. // 发起微信支付
  202. this.$api.wechatPay({
  203. orderNo:this.appointmentOrder.subOrderNo
  204. }).then((res)=>{
  205. var param = res.data.data;
  206. uni.requestPayment({
  207. appId: param.appid,
  208. timeStamp: param.timestamp+"",
  209. nonceStr: param.noncestr,
  210. package: "prepay_id="+param.prepayid,
  211. signType: "RSA",
  212. paySign: param.sign,
  213. success: res => {
  214. this.requestStatus=false
  215. uni.hideLoading();
  216. that.$refs.popup.close()
  217. uni.showToast({
  218. title: '支付成功!'
  219. });
  220. that.$refs.MescrollItem[that.tabIndex].downCallback()
  221. that.getUserInfo()
  222. },
  223. fail: res => {
  224. this.requestStatus=false
  225. uni.hideLoading();
  226. that.$refs.popup.close()
  227. console.log(res)
  228. uni.showToast({
  229. title: '支付失败',
  230. icon: 'error'
  231. });
  232. that.$refs.MescrollItem[that.tabIndex].downCallback()
  233. that.getUserInfo()
  234. }
  235. });
  236. }).catch(err=>{
  237. this.requestStatus=false
  238. })
  239. },
  240. balancePay(){
  241. let that = this;
  242. // if(this.password.length< 6 ){
  243. // uni.showToast({
  244. // title: "交易密码不能小于6位"
  245. // })
  246. // return ;
  247. // }
  248. // this.$refs.passwordPopup.close()
  249. // 用户信息
  250. if (this.openType == 2){
  251. //支付预约费用
  252. this.$api.balancePay({
  253. orderNo: this.appointmentOrder.subOrderNo,
  254. password: ''
  255. }).then((res)=>{
  256. this.requestStatus=false
  257. uni.hideLoading();
  258. that.$refs.popup.close()
  259. uni.showToast({
  260. title: '支付成功'
  261. })
  262. that.$refs.MescrollItem[that.tabIndex].downCallback()
  263. that.getUserInfo()
  264. that.password = ''
  265. }).catch((err) =>{
  266. this.requestStatus=false
  267. uni.hideLoading();
  268. that.$refs.popup.close()
  269. uni.showToast({
  270. title: err.msg,
  271. icon:'error'
  272. })
  273. that.password = ''
  274. });
  275. }else {
  276. //支付子订单费用
  277. this.$api.trade({
  278. tradeNo: this.tradeNo,
  279. password: ''
  280. }).then((res)=>{
  281. this.requestStatus=false
  282. uni.hideLoading();
  283. that.$refs.popup.close()
  284. uni.showToast({
  285. title: '支付成功'
  286. })
  287. that.$refs.MescrollItem[that.tabIndex].downCallback()
  288. that.getUserInfo()
  289. that.password = ''
  290. }).catch((err) =>{
  291. this.requestStatus=false
  292. uni.hideLoading();
  293. that.$refs.popup.close()
  294. uni.showToast({
  295. title: err.msg,
  296. icon:'error'
  297. })
  298. that.password = ''
  299. });
  300. }
  301. },
  302. payItem(num){
  303. console.log(this.userInfo.balance*1,this.appointmentOrder.totalAmount*1)
  304. if (this.userInfo.balance*1 < this.appointmentOrder.totalAmount*1){
  305. return
  306. }
  307. this.curServiceTab = num
  308. },
  309. closePayPopup(){
  310. this.$refs.popup.close()
  311. },
  312. //一键支付子订单
  313. openPay(order,number){
  314. console.log(order)
  315. console.log(number)
  316. this.openType=number
  317. this.appointmentOrder = order
  318. this.$api.oneClickPay({
  319. orderId:order.orderId
  320. }).then(res=>{
  321. this.tradeNo = res.data.data.tradeNo
  322. this.$refs.popup.open()
  323. })
  324. },
  325. commonGeneralOrder(){
  326. if(this.requestStatus){
  327. return;
  328. }
  329. this.requestStatus=true
  330. uni.showLoading({
  331. title: '支付中'
  332. });
  333. let that =this
  334. if (this.curServiceTab===1){
  335. // this.$refs.popup.close()
  336. // that.password = ''
  337. // this.$refs.passwordPopup.open()
  338. this.balancePay()
  339. }else {
  340. if (this.openType == 2){
  341. //支付预约费用
  342. this.wechatPay()
  343. }else{
  344. //支付子订单费用
  345. this.$api.wechatPayTradeNo({tradeNo:this.tradeNo}).then(res=>{
  346. var param = res.data.data;
  347. uni.requestPayment({
  348. appId: param.appid,
  349. timeStamp: param.timestamp+"",
  350. nonceStr: param.noncestr,
  351. package: "prepay_id="+param.prepayid,
  352. signType: "RSA",
  353. paySign: param.sign,
  354. success: res => {
  355. this.requestStatus=false
  356. uni.hideLoading();
  357. uni.showToast({
  358. title: '支付成功!'
  359. });
  360. that.$refs.popup.close()
  361. that.$refs.MescrollItem[that.tabIndex].downCallback()
  362. that.getUserInfo()
  363. },
  364. fail: res => {
  365. console.log(res)
  366. this.requestStatus=false
  367. uni.hideLoading();
  368. uni.showToast({
  369. title: '支付失败',
  370. icon: 'error'
  371. });
  372. that.$refs.popup.close()
  373. that.$refs.MescrollItem[that.tabIndex].downCallback()
  374. that.getUserInfo()
  375. }
  376. });
  377. })
  378. }
  379. }
  380. },
  381. getUserInfo() {
  382. let that = this
  383. this.$api.getUserInfo().then(res => {
  384. that.userInfo = res.data.data
  385. uni.setStorageSync('userInfo', res.data.data);
  386. });
  387. },
  388. clickTab(e) {
  389. this.tabIndex = e.index
  390. },
  391. swiperChange(e) {
  392. this.tabIndex = e.detail.current
  393. },
  394. changeTab(currentTab) {
  395. this.currentTab = currentTab
  396. },
  397. }
  398. }
  399. </script>
  400. <style scoped lang="scss">
  401. @import '/common/css/common.css';
  402. @import './index.rpx.scss';
  403. </style>