index.vue 15 KB

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