index.vue 14 KB

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