index.vue 14 KB

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