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. }).then(res=>{
  272. this.requestStatus=false
  273. uni.hideLoading();
  274. that.$refs.popup.close()
  275. uni.showToast({
  276. title: '支付成功'
  277. })
  278. that.$refs.MescrollItem[that.tabIndex].downCallback()
  279. that.getUserInfo()
  280. that.password = ''
  281. }).catch((err) =>{
  282. this.requestStatus=false
  283. uni.hideLoading();
  284. that.$refs.popup.close()
  285. uni.showToast({
  286. title: err.msg,
  287. icon:'error'
  288. })
  289. that.password = ''
  290. });
  291. }else{
  292. this.$api.familyCardTradePay({
  293. tradeNo:this.tradeNo,
  294. loveCardId:this.loveCardId
  295. }).then(res=>{
  296. this.requestStatus=false
  297. uni.hideLoading();
  298. that.$refs.popup.close()
  299. uni.showToast({
  300. title: '支付成功'
  301. })
  302. that.$refs.MescrollItem[that.tabIndex].downCallback()
  303. that.getUserInfo()
  304. that.password = ''
  305. }).catch((err) =>{
  306. this.requestStatus=false
  307. uni.hideLoading();
  308. that.$refs.popup.close()
  309. uni.showToast({
  310. title: err.msg,
  311. icon:'error'
  312. })
  313. that.password = ''
  314. });
  315. }
  316. },
  317. balancePay(){
  318. let that = this;
  319. // if(this.password.length< 6 ){
  320. // uni.showToast({
  321. // title: "交易密码不能小于6位"
  322. // })
  323. // return ;
  324. // }
  325. // this.$refs.passwordPopup.close()
  326. // 用户信息
  327. if (this.openType == 2){
  328. //支付预约费用
  329. this.$api.balancePay({
  330. orderNo: this.appointmentOrder.subOrderNo,
  331. password: ''
  332. }).then((res)=>{
  333. this.requestStatus=false
  334. uni.hideLoading();
  335. that.$refs.popup.close()
  336. uni.showToast({
  337. title: '支付成功'
  338. })
  339. that.$refs.MescrollItem[that.tabIndex].downCallback()
  340. that.getUserInfo()
  341. that.password = ''
  342. }).catch((err) =>{
  343. this.requestStatus=false
  344. uni.hideLoading();
  345. that.$refs.popup.close()
  346. uni.showToast({
  347. title: err.msg,
  348. icon:'error'
  349. })
  350. that.password = ''
  351. });
  352. }else {
  353. //支付子订单费用
  354. this.$api.trade({
  355. tradeNo: this.tradeNo,
  356. password: ''
  357. }).then((res)=>{
  358. this.requestStatus=false
  359. uni.hideLoading();
  360. that.$refs.popup.close()
  361. uni.showToast({
  362. title: '支付成功'
  363. })
  364. that.$refs.MescrollItem[that.tabIndex].downCallback()
  365. that.getUserInfo()
  366. that.password = ''
  367. }).catch((err) =>{
  368. this.requestStatus=false
  369. uni.hideLoading();
  370. that.$refs.popup.close()
  371. uni.showToast({
  372. title: err.msg,
  373. icon:'error'
  374. })
  375. that.password = ''
  376. });
  377. }
  378. },
  379. payLoveItem(num,index,loveCard){
  380. // console.log(loveCard.totalBalance*1, this.totalAmount*1)
  381. // if (loveCard.totalBalance*1 < this.totalAmount*1 && num == 0){
  382. // console.log(this.totalAmount)
  383. // uni.$u.toast('余额不足')
  384. // return
  385. // }
  386. this.curServiceTab = num
  387. this.loveCardList.forEach(item=>{
  388. item.select = false
  389. })
  390. loveCard.select=true
  391. this.loveCardId = loveCard.id
  392. this.$set(this.loveCardList,index,loveCard)
  393. },
  394. payItem(num){
  395. console.log(this.userInfo.balance*1,this.appointmentOrder.totalAmount*1)
  396. // if (this.loveCard.totalBalance*1 < this.appointmentOrder.totalAmount*1 && num == 0){
  397. // uni.$u.toast('余额不足')
  398. // return
  399. // }
  400. if (this.userInfo.balance*1 < this.payAmount*1 && num == 1){
  401. uni.$u.toast('余额不足')
  402. return
  403. }
  404. this.curServiceTab = num
  405. },
  406. closePayPopup(){
  407. this.$refs.popup.close()
  408. },
  409. //一键支付子订单
  410. openPay(order,number){
  411. console.log(order)
  412. console.log(number)
  413. this.openType=number
  414. this.payAmount = order.payAmount
  415. this.appointmentOrder = order
  416. this.$api.oneClickPay({
  417. orderId:order.orderId
  418. }).then(res=>{
  419. this.tradeNo = res.data.data.tradeNo
  420. this.$refs.popup.open()
  421. })
  422. },
  423. commonGeneralOrder(){
  424. if(this.requestStatus){
  425. return;
  426. }
  427. this.requestStatus=true
  428. uni.showLoading({
  429. title: '支付中'
  430. });
  431. let that =this
  432. if (this.curServiceTab===0){
  433. this.familyCardPay()
  434. }
  435. if (this.curServiceTab===1){
  436. // this.$refs.popup.close()
  437. // that.password = ''
  438. // this.$refs.passwordPopup.open()
  439. this.balancePay()
  440. }
  441. if (this.curServiceTab===2) {
  442. if (this.openType == 2){
  443. //支付预约费用
  444. this.wechatPay()
  445. }else{
  446. //支付子订单费用
  447. this.$api.wechatPayTradeNo({tradeNo:this.tradeNo}).then(res=>{
  448. var param = res.data.data;
  449. uni.requestPayment({
  450. appId: param.appid,
  451. timeStamp: param.timestamp+"",
  452. nonceStr: param.noncestr,
  453. package: "prepay_id="+param.prepayid,
  454. signType: "RSA",
  455. paySign: param.sign,
  456. success: res => {
  457. this.requestStatus=false
  458. uni.hideLoading();
  459. uni.showToast({
  460. title: '支付成功!'
  461. });
  462. that.$refs.popup.close()
  463. that.$refs.MescrollItem[that.tabIndex].downCallback()
  464. that.getUserInfo()
  465. },
  466. fail: res => {
  467. console.log(res)
  468. this.requestStatus=false
  469. uni.hideLoading();
  470. uni.showToast({
  471. title: '支付失败',
  472. icon: 'error'
  473. });
  474. that.$refs.popup.close()
  475. that.$refs.MescrollItem[that.tabIndex].downCallback()
  476. that.getUserInfo()
  477. }
  478. });
  479. })
  480. }
  481. }
  482. },
  483. getUserInfo() {
  484. let that = this
  485. this.$api.getUserInfo().then(res => {
  486. that.userInfo = res.data.data
  487. uni.setStorageSync('userInfo', res.data.data);
  488. });
  489. },
  490. clickTab(e) {
  491. this.tabIndex = e.index
  492. },
  493. swiperChange(e) {
  494. this.tabIndex = e.detail.current
  495. },
  496. changeTab(currentTab) {
  497. this.currentTab = currentTab
  498. },
  499. getMyReceiveList(){
  500. this.$api.getMyReceiveList().then(res=>{
  501. this.loveCardList = res.data.data
  502. })
  503. }
  504. }
  505. }
  506. </script>
  507. <style scoped lang="scss">
  508. @import '/common/css/common.css';
  509. @import './index.rpx.scss';
  510. </style>