index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  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>预计等待时间{{orderNumberData.minWaitTime }}到{{orderNumberData.maxWaitTime }}分钟</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="{'min-height':'380rpx'}">
  67. <view v-if="loveCardList.length>0" class="payItem flex-row" >
  68. <u-icon name="/static/me/familyCard_icon.png" color="#38db38" size="36"></u-icon>
  69. <view class="payName flex-col justify-center flex-grow">
  70. <text>亲情卡支付</text>
  71. <scroll-view scroll-y class="loveCard">
  72. <view class="flex-row justify-between loveCardItem " v-for="(item,index) in loveCardList" :key="index" @click="payLoveItem(0,index,item)">
  73. <view class="select flex-col" >
  74. <text>{{item.presentUserName}}({{item.presentUserNo}})</text>
  75. <text class="balance">可用余额:{{item.totalBalance}}</text>
  76. </view>
  77. <view class="flex-col justify-center">
  78. <u-icon v-if="curServiceTab === 0 && item.select" name="checkmark-circle-fill" color="#38db38" size="25"></u-icon>
  79. <u-icon v-else name="/static/order/ud9.png" color="green" size="25"></u-icon>
  80. </view>
  81. </view>
  82. </scroll-view>
  83. </view>
  84. </view>
  85. <view class="payItem flex-row justify-between" @click="payItem(1)">
  86. <view class="flex-row">
  87. <u-icon name="/static/me/u701.png" color="#38db38" size="36"></u-icon>
  88. <view class="payName flex-col justify-center">
  89. <text>余额支付</text>
  90. <text class="balance">可用余额{{userInfo.balance || 0}}</text>
  91. <!-- <text class="balance">应付金额{{payAmount}}</text>-->
  92. </view>
  93. </view>
  94. <view class="flex-col justify-center">
  95. <view v-if="curServiceTab === 1" >
  96. <u-icon name="checkmark-circle-fill" color="#38db38" size="25"></u-icon>
  97. </view>
  98. <view v-else>
  99. <u-icon name="/static/order/ud9.png" color="green" size="25"></u-icon>
  100. </view>
  101. </view>
  102. </view>
  103. <view class="payItem flex-row justify-between" @click="payItem(2)">
  104. <view class="flex-row">
  105. <u-icon name="weixin-circle-fill" color="#38db38" size="36"></u-icon>
  106. <view class="payName flex-col justify-center">
  107. <text>微信支付</text>
  108. </view>
  109. </view>
  110. <view class="flex-col justify-center">
  111. <view v-if="curServiceTab === 2" >
  112. <u-icon name="checkmark-circle-fill" color="#38db38" size="25"></u-icon>
  113. </view>
  114. <view v-else>
  115. <u-icon name="/static/order/ud9.png" color="green" size="25"></u-icon>
  116. </view>
  117. </view>
  118. </view>
  119. </view>
  120. <view class="commitBtn" @click="commonGeneralOrder">
  121. <text>确定</text>
  122. </view>
  123. </view>
  124. </uni-popup>
  125. <uni-popup ref="passwordPopup">
  126. <view class="passwordView flex-col">
  127. <view class="flex-row justify-center">
  128. <text>请输入交易密码</text>
  129. </view>
  130. <view class="h-tab-bar flex-row justify-center">
  131. <u-code-input v-model="password" mode="box" dot></u-code-input>
  132. </view>
  133. <view class="flex-row justify-center">
  134. <view class="h-operate-btn flex-row justify-center" @click="balancePay">
  135. <text>确定</text>
  136. </view>
  137. </view>
  138. </view>
  139. </uni-popup>
  140. </view>
  141. </template>
  142. <script>
  143. import MescrollItem from "./module/mescrollUni-item.vue";
  144. import tabBar from "../../components/tabBar/tabBar";
  145. export default {
  146. components: {
  147. tabBar,
  148. MescrollItem
  149. },
  150. data() {
  151. return {
  152. orderNumberData:{},
  153. num: 0,
  154. payAmount:'',//调用支付组件时需要支付的金额
  155. title: 'Hello',
  156. tabIndex: 0,
  157. tabBarIndex:3,
  158. currentTab: 0,
  159. currentServiceTab: 'orderTab1',
  160. queueingMsgData:{},
  161. tabList: [{
  162. name: '全部'
  163. }, {
  164. name: '当前订单'
  165. }, {
  166. name: '待付款'
  167. }, {
  168. name: '已完成'
  169. }],
  170. windowHeight: '',
  171. userInfo:{},
  172. curServiceTab:2,
  173. tradeNo:'',
  174. password:'',
  175. openType:0,//开启的支付类型:1一键支付子订单费用,2:支付预约费用
  176. appointmentOrder:{},
  177. requestStatus : false,
  178. loveCardId:'',
  179. loveCardList:[]
  180. }
  181. },
  182. onLoad() {
  183. // uni.hideTabBar({
  184. // animation: false
  185. // })
  186. let sysInfo = uni.getSystemInfoSync()
  187. console.log(sysInfo,'2222222222222222222222222')
  188. this.windowHeight = sysInfo.windowHeight - 74 + 'px' //除标题栏栏外的屏幕可用高度
  189. this.$off()
  190. this.$on('orderListIndex',this.listenerIndex)
  191. },
  192. onShow(){
  193. this.userInfo = uni.getStorageSync('userInfo')
  194. if (uni.getStorageSync('orderListIndex')){
  195. this.tabIndex = uni.getStorageSync('orderListIndex')
  196. }
  197. uni.removeStorageSync('orderListIndex');
  198. this.$refs.MescrollItem[this.tabIndex].downCallback()
  199. this.getMyReceiveList()
  200. },
  201. methods: {
  202. serialNumber(order){
  203. this.$api.viewNumber(order.orderId).then(res=>{
  204. this.orderNumberData = res.data.data
  205. this.$refs.serialNumber.open()
  206. })
  207. },
  208. getQueueingMsg(order){
  209. this.$api.queueInfo(order.orderId).then(res=>{
  210. this.queueingMsgData = res.data.data
  211. })
  212. this.$refs.getQueueingMsg.open()
  213. },
  214. openPayAppointment(order,number){
  215. console.log(order)
  216. console.log(number)
  217. this.payAmount = order.subAmount
  218. this.appointmentOrder = order
  219. this.openType=number
  220. this.$refs.popup.open()
  221. },
  222. //微信支付预约费用
  223. wechatPay(){
  224. let that = this;
  225. // 发起微信支付
  226. this.$api.wechatPay({
  227. orderNo:this.appointmentOrder.subOrderNo
  228. }).then((res)=>{
  229. var param = res.data.data;
  230. uni.requestPayment({
  231. appId: param.appid,
  232. timeStamp: param.timestamp+"",
  233. nonceStr: param.noncestr,
  234. package: "prepay_id="+param.prepayid,
  235. signType: "RSA",
  236. paySign: param.sign,
  237. success: res => {
  238. this.requestStatus=false
  239. uni.hideLoading();
  240. that.$refs.popup.close()
  241. uni.showToast({
  242. title: '支付成功!'
  243. });
  244. that.$refs.MescrollItem[that.tabIndex].downCallback()
  245. that.getUserInfo()
  246. },
  247. fail: res => {
  248. this.requestStatus=false
  249. uni.hideLoading();
  250. that.$refs.popup.close()
  251. console.log(res)
  252. uni.showToast({
  253. title: '支付失败',
  254. icon: 'error'
  255. });
  256. that.$refs.MescrollItem[that.tabIndex].downCallback()
  257. that.getUserInfo()
  258. }
  259. });
  260. }).catch(err=>{
  261. this.requestStatus=false
  262. })
  263. },
  264. familyCardPay(){
  265. let that = this;
  266. if (this.openType == 2){
  267. this.$api.familyCardPay({
  268. orderNo: this.appointmentOrder.subOrderNo,
  269. loveCardId: this.loveCardId
  270. }).then(res=>{
  271. this.requestStatus=false
  272. uni.hideLoading();
  273. that.$refs.popup.close()
  274. uni.showToast({
  275. title: '支付成功'
  276. })
  277. that.$refs.MescrollItem[that.tabIndex].downCallback()
  278. that.getUserInfo()
  279. that.password = ''
  280. }).catch((err) =>{
  281. this.requestStatus=false
  282. uni.hideLoading();
  283. that.$refs.popup.close()
  284. uni.showToast({
  285. title: err.msg,
  286. icon:'error'
  287. })
  288. that.password = ''
  289. });
  290. }else{
  291. this.$api.familyCardTradePay({
  292. tradeNo:this.tradeNo,
  293. loveCardId:this.loveCardId
  294. }).then(res=>{
  295. this.requestStatus=false
  296. uni.hideLoading();
  297. that.$refs.popup.close()
  298. uni.showToast({
  299. title: '支付成功'
  300. })
  301. that.$refs.MescrollItem[that.tabIndex].downCallback()
  302. that.getUserInfo()
  303. that.password = ''
  304. }).catch((err) =>{
  305. this.requestStatus=false
  306. uni.hideLoading();
  307. that.$refs.popup.close()
  308. uni.showToast({
  309. title: err.msg,
  310. icon:'error'
  311. })
  312. that.password = ''
  313. });
  314. }
  315. },
  316. balancePay(){
  317. let that = this;
  318. // if(this.password.length< 6 ){
  319. // uni.showToast({
  320. // title: "交易密码不能小于6位"
  321. // })
  322. // return ;
  323. // }
  324. // this.$refs.passwordPopup.close()
  325. // 用户信息
  326. if (this.openType == 2){
  327. //支付预约费用
  328. this.$api.balancePay({
  329. orderNo: this.appointmentOrder.subOrderNo,
  330. password: ''
  331. }).then((res)=>{
  332. this.requestStatus=false
  333. uni.hideLoading();
  334. that.$refs.popup.close()
  335. uni.showToast({
  336. title: '支付成功'
  337. })
  338. that.$refs.MescrollItem[that.tabIndex].downCallback()
  339. that.getUserInfo()
  340. that.password = ''
  341. }).catch((err) =>{
  342. this.requestStatus=false
  343. uni.hideLoading();
  344. that.$refs.popup.close()
  345. uni.showToast({
  346. title: err.msg,
  347. icon:'error'
  348. })
  349. that.password = ''
  350. });
  351. }else {
  352. //支付子订单费用
  353. this.$api.trade({
  354. tradeNo: this.tradeNo,
  355. password: ''
  356. }).then((res)=>{
  357. this.requestStatus=false
  358. uni.hideLoading();
  359. that.$refs.popup.close()
  360. uni.showToast({
  361. title: '支付成功'
  362. })
  363. that.$refs.MescrollItem[that.tabIndex].downCallback()
  364. that.getUserInfo()
  365. that.password = ''
  366. }).catch((err) =>{
  367. this.requestStatus=false
  368. uni.hideLoading();
  369. that.$refs.popup.close()
  370. uni.showToast({
  371. title: err.msg,
  372. icon:'error'
  373. })
  374. that.password = ''
  375. });
  376. }
  377. },
  378. payLoveItem(num,index,loveCard){
  379. console.log(loveCard.totalBalance*1, this.totalAmount*1)
  380. if (loveCard.totalBalance*1 < this.totalAmount*1 && num == 0){
  381. console.log(this.totalAmount)
  382. uni.$u.toast('余额不足')
  383. return
  384. }
  385. this.curServiceTab = num
  386. this.loveCardList.forEach(item=>{
  387. item.select = false
  388. })
  389. loveCard.select=true
  390. this.loveCardId = loveCard.id
  391. this.$set(this.loveCardList,index,loveCard)
  392. },
  393. payItem(num){
  394. console.log(this.userInfo.balance*1,this.appointmentOrder.totalAmount*1)
  395. if (this.userInfo.balance*1 < this.payAmount*1){
  396. uni.$u.toast('余额不足')
  397. return
  398. }
  399. this.curServiceTab = num
  400. },
  401. closePayPopup(){
  402. this.$refs.popup.close()
  403. },
  404. //一键支付子订单
  405. openPay(order,number){
  406. console.log(order)
  407. console.log(number)
  408. this.openType=number
  409. this.payAmount = order.payAmount
  410. this.appointmentOrder = order
  411. this.$api.oneClickPay({
  412. orderId:order.orderId
  413. }).then(res=>{
  414. this.tradeNo = res.data.data.tradeNo
  415. this.$refs.popup.open()
  416. })
  417. },
  418. commonGeneralOrder(){
  419. if(this.requestStatus){
  420. return;
  421. }
  422. this.requestStatus=true
  423. uni.showLoading({
  424. title: '支付中'
  425. });
  426. let that =this
  427. if (this.curServiceTab===0){
  428. this.familyCardPay()
  429. }
  430. if (this.curServiceTab===1){
  431. // this.$refs.popup.close()
  432. // that.password = ''
  433. // this.$refs.passwordPopup.open()
  434. this.balancePay()
  435. }
  436. if (this.curServiceTab===2) {
  437. if (this.openType == 2){
  438. //支付预约费用
  439. this.wechatPay()
  440. }else{
  441. //支付子订单费用
  442. this.$api.wechatPayTradeNo({tradeNo:this.tradeNo}).then(res=>{
  443. var param = res.data.data;
  444. uni.requestPayment({
  445. appId: param.appid,
  446. timeStamp: param.timestamp+"",
  447. nonceStr: param.noncestr,
  448. package: "prepay_id="+param.prepayid,
  449. signType: "RSA",
  450. paySign: param.sign,
  451. success: res => {
  452. this.requestStatus=false
  453. uni.hideLoading();
  454. uni.showToast({
  455. title: '支付成功!'
  456. });
  457. that.$refs.popup.close()
  458. that.$refs.MescrollItem[that.tabIndex].downCallback()
  459. that.getUserInfo()
  460. },
  461. fail: res => {
  462. console.log(res)
  463. this.requestStatus=false
  464. uni.hideLoading();
  465. uni.showToast({
  466. title: '支付失败',
  467. icon: 'error'
  468. });
  469. that.$refs.popup.close()
  470. that.$refs.MescrollItem[that.tabIndex].downCallback()
  471. that.getUserInfo()
  472. }
  473. });
  474. })
  475. }
  476. }
  477. },
  478. getUserInfo() {
  479. let that = this
  480. this.$api.getUserInfo().then(res => {
  481. that.userInfo = res.data.data
  482. uni.setStorageSync('userInfo', res.data.data);
  483. });
  484. },
  485. clickTab(e) {
  486. this.tabIndex = e.index
  487. },
  488. swiperChange(e) {
  489. this.tabIndex = e.detail.current
  490. },
  491. changeTab(currentTab) {
  492. this.currentTab = currentTab
  493. },
  494. getMyReceiveList(){
  495. this.$api.getMyReceiveList().then(res=>{
  496. this.loveCardList = res.data.data
  497. })
  498. }
  499. }
  500. }
  501. </script>
  502. <style scoped lang="scss">
  503. @import '/common/css/common.css';
  504. @import './index.rpx.scss';
  505. </style>