index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. <template>
  2. <view class="content">
  3. <u-sticky>
  4. <!-- <view ref="hContentWrap" class="hContentWrap h-content-wrap">-->
  5. <!-- <view class="tab-bar">-->
  6. <!-- <view class="tab-item" :class="{ active: currentTab === 0 }" @click="changeTab(0)">-->
  7. <!-- 服务订单-->
  8. <!-- </view>-->
  9. <!-- <view class="tab-item" :class="{ active: currentTab === 1 }" @click="changeTab(1)">-->
  10. <!-- 产品订单-->
  11. <!-- </view>-->
  12. <!-- </view>-->
  13. <!-- </view>-->
  14. <View class=" tabs">
  15. <u-tabs :list="tabList" :scrollable="false" lineWidth="30" lineColor="#FFE05C" :activeStyle="{
  16. color: '#333333',
  17. fontWeight: 'bold',
  18. transform: 'scale(1.05)'
  19. }" :current="tabIndex" @click="clickTab"></u-tabs>
  20. </View>
  21. </u-sticky>
  22. <!-- 订单列表 -->
  23. <view :style="{'height':windowHeight}">
  24. <swiper :style="{'height':windowHeight}" :current="tabIndex" @change="swiperChange">
  25. <swiper-item class="swiperItem" v-for="(item,index) in tabList" :key="index">
  26. <view>
  27. <mescroll-item ref="MescrollItem" :i="index" :index="tabIndex" :tabs="tabList" :height="windowHeight" @serialNumber="serialNumber" @openPay="openPay" @openPayAppointment="openPayAppointment">
  28. </mescroll-item>
  29. </view>
  30. </swiper-item>
  31. </swiper>
  32. </view>
  33. <!-- <view class="product-order" v-if="currentTab === 1">-->
  34. <!-- &lt;!&ndash; Tab 2 内容 &ndash;&gt;-->
  35. <!-- <view class="developing">-->
  36. <!-- <text>敬请期待...</text>-->
  37. <!-- </view>-->
  38. <!-- </view>-->
  39. <uni-popup ref="serialNumber">
  40. <view class="serial-number">
  41. <view class="text">
  42. <text>您的排队号</text>
  43. </view>
  44. <view class="number">
  45. <text>{{ orderNumberData.schedulingNo }}</text>
  46. </view>
  47. <view v-if="orderNumberData.overNo" class="text1">
  48. <text>已过号,请重新取号</text>
  49. </view>
  50. <view v-else class="text">
  51. <text>前面还有{{ orderNumberData.waitNoNum }}人在等待</text>
  52. </view>
  53. <view class="text">
  54. <text>随时关注小程序的排队进程,过号作废</text>
  55. </view>
  56. <!-- <view class="text">-->
  57. <!-- <text>0851—85833828</text>-->
  58. <!-- </view>-->
  59. </view>
  60. </uni-popup>
  61. <uni-popup ref="popup" :catchtouchmove="true" :animation="false" type="bottom">
  62. <view class=" payView">
  63. <view class="flex-row justify-between">
  64. <text class="payType">请选择支付方式</text>
  65. <image class="x" src="/static/common/ox.png" @click="closePayPopup"></image>
  66. </view>
  67. <view class="payTitle">
  68. <text>选择微信支付或余额支付</text>
  69. </view>
  70. <view :style="{'height':'380rpx'}">
  71. <view class="payItem flex-row justify-between" v-if="openType!=2" @click="payItem(1)">
  72. <view class="flex-row">
  73. <u-icon name="/static/me/u701.png" color="#38db38" size="36"></u-icon>
  74. <view class="payName flex-col justify-center">
  75. <text>余额支付</text>
  76. <text class="balance">可以余额¥{{userInfo.balance || 0}}</text>
  77. </view>
  78. </view>
  79. <view class="flex-col justify-center">
  80. <view v-if="curServiceTab === 1" >
  81. <u-icon name="checkmark-circle-fill" color="#38db38" size="25"></u-icon>
  82. </view>
  83. <view v-else>
  84. <u-icon name="/static/order/ud9.png" color="green" size="25"></u-icon>
  85. </view>
  86. </view>
  87. </view>
  88. <view class="payItem flex-row justify-between" @click="payItem(2)">
  89. <view class="flex-row">
  90. <u-icon name="weixin-circle-fill" color="#38db38" size="36"></u-icon>
  91. <view class="payName flex-col justify-center">
  92. <text>微信支付</text>
  93. </view>
  94. </view>
  95. <view class="flex-col justify-center">
  96. <view v-if="curServiceTab === 2" >
  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>
  105. <view class="commitBtn" @click="commonGeneralOrder">
  106. <text>确定</text>
  107. </view>
  108. </view>
  109. </uni-popup>
  110. <uni-popup ref="passwordPopup">
  111. <view class="passwordView flex-col">
  112. <view class="flex-row justify-center">
  113. <text>请输入交易密码</text>
  114. </view>
  115. <view class="h-tab-bar flex-row justify-center">
  116. <u-code-input v-model="password" mode="box" dot></u-code-input>
  117. </view>
  118. <view class="flex-row justify-center">
  119. <view class="h-operate-btn flex-row justify-center" @click="balancePay">
  120. <text>确定</text>
  121. </view>
  122. </view>
  123. </view>
  124. </uni-popup>
  125. <!-- <view class="tabBarLineHeight"></view>-->
  126. <view class="tabBarView">
  127. <tab-bar :tabIndex="tabBarIndex"></tab-bar>
  128. </view>
  129. </view>
  130. </template>
  131. <script>
  132. import MescrollItem from "./module/mescrollUni-item.vue";
  133. import tabBar from "../../components/tabBar/tabBar";
  134. export default {
  135. components: {
  136. tabBar,
  137. MescrollItem
  138. },
  139. data() {
  140. return {
  141. orderNumberData:{},
  142. num: 0,
  143. title: 'Hello',
  144. tabIndex: 0,
  145. tabBarIndex:3,
  146. currentTab: 0,
  147. currentServiceTab: 'orderTab1',
  148. tabList: [{
  149. name: '全部'
  150. }, {
  151. name: '当前订单'
  152. }, {
  153. name: '待付款'
  154. }, {
  155. name: '已完成'
  156. }],
  157. windowHeight: '',
  158. userInfo:{},
  159. curServiceTab:2,
  160. tradeNo:'',
  161. password:'',
  162. openType:0,//开启的支付类型:1一键支付子订单费用,2:支付预约费用
  163. appointmentOrder:{},
  164. requestStatus : false
  165. }
  166. },
  167. onLoad() {
  168. uni.hideTabBar({
  169. animation: false
  170. })
  171. let sysInfo = uni.getSystemInfoSync()
  172. console.log(sysInfo,'2222222222222222222222222')
  173. this.windowHeight = sysInfo.windowHeight - 74 + 'px' //除标题栏栏外的屏幕可用高度
  174. this.$off()
  175. this.$on('orderListIndex',this.listenerIndex)
  176. },
  177. onShow(){
  178. this.userInfo = uni.getStorageSync('userInfo')
  179. if (uni.getStorageSync('orderListIndex')){
  180. this.tabIndex = uni.getStorageSync('orderListIndex')
  181. }
  182. uni.removeStorageSync('orderListIndex');
  183. this.$refs.MescrollItem[this.tabIndex].downCallback()
  184. },
  185. methods: {
  186. serialNumber(order){
  187. this.$api.viewNumber(order.orderId).then(res=>{
  188. this.orderNumberData = res.data.data
  189. })
  190. this.$refs.serialNumber.open()
  191. },
  192. openPayAppointment(order,number){
  193. console.log(order)
  194. console.log(number)
  195. this.appointmentOrder = order
  196. this.openType=number
  197. this.$refs.popup.open()
  198. },
  199. //微信支付预约费用
  200. wechatPay(){
  201. let that = this;
  202. // 发起微信支付
  203. this.$api.wechatPay({
  204. orderNo:this.appointmentOrder.subOrderNo
  205. }).then((res)=>{
  206. var param = res.data.data;
  207. uni.requestPayment({
  208. appId: param.appid,
  209. timeStamp: param.timestamp+"",
  210. nonceStr: param.noncestr,
  211. package: "prepay_id="+param.prepayid,
  212. signType: "RSA",
  213. paySign: param.sign,
  214. success: res => {
  215. this.requestStatus=false
  216. uni.hideLoading();
  217. that.$refs.popup.close()
  218. uni.showToast({
  219. title: '支付成功!'
  220. });
  221. that.$refs.MescrollItem[that.tabIndex].downCallback()
  222. that.getUserInfo()
  223. },
  224. fail: res => {
  225. this.requestStatus=false
  226. uni.hideLoading();
  227. that.$refs.popup.close()
  228. console.log(res)
  229. uni.showToast({
  230. title: '支付失败',
  231. icon: 'error'
  232. });
  233. that.$refs.MescrollItem[that.tabIndex].downCallback()
  234. that.getUserInfo()
  235. }
  236. });
  237. }).catch(err=>{
  238. this.requestStatus=false
  239. })
  240. },
  241. balancePay(){
  242. let that = this;
  243. // if(this.password.length< 6 ){
  244. // uni.showToast({
  245. // title: "交易密码不能小于6位"
  246. // })
  247. // return ;
  248. // }
  249. // this.$refs.passwordPopup.close()
  250. // 用户信息
  251. if (this.openType == 2){
  252. //支付预约费用
  253. this.$api.balancePay({
  254. orderNo: this.appointmentOrder.subOrderNo,
  255. password: ''
  256. }).then((res)=>{
  257. this.requestStatus=false
  258. uni.hideLoading();
  259. that.$refs.popup.close()
  260. uni.showToast({
  261. title: '支付成功'
  262. })
  263. that.$refs.MescrollItem[that.tabIndex].downCallback()
  264. that.getUserInfo()
  265. that.password = ''
  266. }).catch((err) =>{
  267. this.requestStatus=false
  268. uni.hideLoading();
  269. that.$refs.popup.close()
  270. uni.showToast({
  271. title: err.msg,
  272. icon:'error'
  273. })
  274. that.password = ''
  275. });
  276. }else {
  277. //支付子订单费用
  278. this.$api.trade({
  279. tradeNo: this.tradeNo,
  280. password: ''
  281. }).then((res)=>{
  282. this.requestStatus=false
  283. uni.hideLoading();
  284. that.$refs.popup.close()
  285. uni.showToast({
  286. title: '支付成功'
  287. })
  288. that.$refs.MescrollItem[that.tabIndex].downCallback()
  289. that.getUserInfo()
  290. that.password = ''
  291. }).catch((err) =>{
  292. this.requestStatus=false
  293. uni.hideLoading();
  294. that.$refs.popup.close()
  295. uni.showToast({
  296. title: err.msg,
  297. icon:'error'
  298. })
  299. that.password = ''
  300. });
  301. }
  302. },
  303. payItem(num){
  304. console.log(this.userInfo.balance*1,this.appointmentOrder.totalAmount*1)
  305. if (this.userInfo.balance*1 < this.appointmentOrder.totalAmount*1){
  306. return
  307. }
  308. this.curServiceTab = num
  309. },
  310. closePayPopup(){
  311. this.$refs.popup.close()
  312. },
  313. //一键支付子订单
  314. openPay(order,number){
  315. console.log(order)
  316. console.log(number)
  317. this.openType=number
  318. this.appointmentOrder = order
  319. this.$api.oneClickPay({
  320. orderId:order.orderId
  321. }).then(res=>{
  322. this.tradeNo = res.data.data.tradeNo
  323. this.$refs.popup.open()
  324. })
  325. },
  326. commonGeneralOrder(){
  327. if(this.requestStatus){
  328. return;
  329. }
  330. this.requestStatus=true
  331. uni.showLoading({
  332. title: '支付中'
  333. });
  334. let that =this
  335. if (this.curServiceTab===1){
  336. // this.$refs.popup.close()
  337. // that.password = ''
  338. // this.$refs.passwordPopup.open()
  339. this.balancePay()
  340. }else {
  341. if (this.openType == 2){
  342. //支付预约费用
  343. this.wechatPay()
  344. }else{
  345. //支付子订单费用
  346. this.$api.wechatPayTradeNo({tradeNo:this.tradeNo}).then(res=>{
  347. var param = res.data.data;
  348. uni.requestPayment({
  349. appId: param.appid,
  350. timeStamp: param.timestamp+"",
  351. nonceStr: param.noncestr,
  352. package: "prepay_id="+param.prepayid,
  353. signType: "RSA",
  354. paySign: param.sign,
  355. success: res => {
  356. this.requestStatus=false
  357. uni.hideLoading();
  358. uni.showToast({
  359. title: '支付成功!'
  360. });
  361. that.$refs.popup.close()
  362. that.$refs.MescrollItem[that.tabIndex].downCallback()
  363. that.getUserInfo()
  364. },
  365. fail: res => {
  366. console.log(res)
  367. this.requestStatus=false
  368. uni.hideLoading();
  369. uni.showToast({
  370. title: '支付失败',
  371. icon: 'error'
  372. });
  373. that.$refs.popup.close()
  374. that.$refs.MescrollItem[that.tabIndex].downCallback()
  375. that.getUserInfo()
  376. }
  377. });
  378. })
  379. }
  380. }
  381. },
  382. getUserInfo() {
  383. let that = this
  384. this.$api.getUserInfo().then(res => {
  385. that.userInfo = res.data.data
  386. uni.setStorageSync('userInfo', res.data.data);
  387. });
  388. },
  389. clickTab(e) {
  390. this.tabIndex = e.index
  391. },
  392. swiperChange(e) {
  393. this.tabIndex = e.detail.current
  394. },
  395. changeTab(currentTab) {
  396. this.currentTab = currentTab
  397. },
  398. }
  399. }
  400. </script>
  401. <style scoped lang="scss">
  402. @import '/common/css/common.css';
  403. @import './index.rpx.scss';
  404. </style>