index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  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 class="payItem flex-row justify-between" @click="payItem(1)">
  71. <view class="flex-row">
  72. <u-icon name="/static/me/u701.png" color="#38db38" size="36"></u-icon>
  73. <view class="payName flex-col justify-center">
  74. <text>余额支付</text>
  75. <text class="balance">可以余额¥{{userInfo.balance || 0}}</text>
  76. </view>
  77. </view>
  78. <view class="flex-col justify-center">
  79. <view v-if="curServiceTab === 1" >
  80. <u-icon name="checkmark-circle-fill" color="#38db38" size="25"></u-icon>
  81. </view>
  82. <view v-else>
  83. <u-icon name="/static/order/ud9.png" color="green" size="25"></u-icon>
  84. </view>
  85. </view>
  86. </view>
  87. <view class="payItem flex-row justify-between" @click="payItem(2)">
  88. <view class="flex-row">
  89. <u-icon name="weixin-circle-fill" color="#38db38" size="36"></u-icon>
  90. <view class="payName flex-col justify-center">
  91. <text>微信支付</text>
  92. </view>
  93. </view>
  94. <view class="flex-col justify-center">
  95. <view v-if="curServiceTab === 2" >
  96. <u-icon name="checkmark-circle-fill" color="#38db38" size="25"></u-icon>
  97. </view>
  98. <view v-else>
  99. <u-icon name="/static/order/ud9.png" color="green" size="25"></u-icon>
  100. </view>
  101. </view>
  102. </view>
  103. <view class="commitBtn" @click="commonGeneralOrder">
  104. <text>确定</text>
  105. </view>
  106. </view>
  107. </uni-popup>
  108. <uni-popup ref="passwordPopup">
  109. <view class="passwordView flex-col">
  110. <view class="flex-row justify-center">
  111. <text>请输入交易密码</text>
  112. </view>
  113. <view class="h-tab-bar flex-row justify-center">
  114. <u-code-input v-model="password" mode="box" dot></u-code-input>
  115. </view>
  116. <view class="flex-row justify-center">
  117. <view class="h-operate-btn flex-row justify-center" @click="balancePay">
  118. <text>确定</text>
  119. </view>
  120. </view>
  121. </view>
  122. </uni-popup>
  123. <!-- <view class="tabBarLineHeight"></view>-->
  124. <view class="tabBarView">
  125. <tab-bar :tabIndex="tabBarIndex"></tab-bar>
  126. </view>
  127. </view>
  128. </template>
  129. <script>
  130. import MescrollItem from "./module/mescrollUni-item.vue";
  131. import tabBar from "../../components/tabBar/tabBar";
  132. export default {
  133. components: {
  134. tabBar,
  135. MescrollItem
  136. },
  137. data() {
  138. return {
  139. orderNumberData:{},
  140. num: 0,
  141. title: 'Hello',
  142. tabIndex: 0,
  143. tabBarIndex:3,
  144. currentTab: 0,
  145. currentServiceTab: 'orderTab1',
  146. tabList: [{
  147. name: '全部'
  148. }, {
  149. name: '当前订单'
  150. }, {
  151. name: '待付款'
  152. }, {
  153. name: '已完成'
  154. }],
  155. windowHeight: '',
  156. userInfo:{},
  157. curServiceTab:2,
  158. tradeNo:'',
  159. password:'',
  160. openType:0,//开启的支付类型:1一键支付子订单费用,2:支付预约费用
  161. appointmentOrder:{}
  162. }
  163. },
  164. onLoad() {
  165. uni.hideTabBar({
  166. animation: false
  167. })
  168. let sysInfo = uni.getSystemInfoSync()
  169. console.log(sysInfo,'2222222222222222222222222')
  170. this.windowHeight = sysInfo.windowHeight - 74 + 'px' //除标题栏栏外的屏幕可用高度
  171. this.$off()
  172. this.$on('orderListIndex',this.listenerIndex)
  173. },
  174. onShow(){
  175. this.userInfo = uni.getStorageSync('userInfo')
  176. if (uni.getStorageSync('orderListIndex')){
  177. this.tabIndex = uni.getStorageSync('orderListIndex')
  178. }
  179. uni.removeStorageSync('orderListIndex');
  180. this.$refs.MescrollItem[this.tabIndex].downCallback()
  181. },
  182. methods: {
  183. serialNumber(order){
  184. this.$api.viewNumber(order.orderId).then(res=>{
  185. this.orderNumberData = res.data.data
  186. })
  187. this.$refs.serialNumber.open()
  188. },
  189. openPayAppointment(order,number){
  190. console.log(order)
  191. console.log(number)
  192. this.appointmentOrder = order
  193. this.openType=number
  194. this.$refs.popup.open()
  195. },
  196. //微信支付预约费用
  197. wechatPay(){
  198. let that = this;
  199. // 发起微信支付
  200. this.$api.wechatPay({
  201. orderNo:this.appointmentOrder.subOrderNo
  202. }).then((res)=>{
  203. var param = res.data.data;
  204. uni.requestPayment({
  205. appId: param.appid,
  206. timeStamp: param.timestamp+"",
  207. nonceStr: param.noncestr,
  208. package: "prepay_id="+param.prepayid,
  209. signType: "RSA",
  210. paySign: param.sign,
  211. success: res => {
  212. that.$refs.popup.close()
  213. uni.showToast({
  214. title: '支付成功!'
  215. });
  216. that.$refs.MescrollItem[that.tabIndex].downCallback()
  217. that.getUserInfo()
  218. },
  219. fail: res => {
  220. that.$refs.popup.close()
  221. console.log(res)
  222. uni.showToast({
  223. title: '支付失败',
  224. icon: 'error'
  225. });
  226. that.$refs.MescrollItem[that.tabIndex].downCallback()
  227. that.getUserInfo()
  228. }
  229. });
  230. })
  231. },
  232. balancePay(){
  233. let that = this;
  234. // if(this.password.length< 6 ){
  235. // uni.showToast({
  236. // title: "交易密码不能小于6位"
  237. // })
  238. // return ;
  239. // }
  240. // this.$refs.passwordPopup.close()
  241. // 用户信息
  242. if (this.openType == 2){
  243. //支付预约费用
  244. this.$api.balancePay({
  245. orderNo: this.appointmentOrder.subOrderNo,
  246. password: ''
  247. }).then((res)=>{
  248. that.$refs.popup.close()
  249. uni.showToast({
  250. title: '支付成功'
  251. })
  252. that.$refs.MescrollItem[that.tabIndex].downCallback()
  253. that.getUserInfo()
  254. that.password = ''
  255. }).catch((err) =>{
  256. that.$refs.popup.close()
  257. uni.showToast({
  258. title: err.msg,
  259. icon:'error'
  260. })
  261. that.password = ''
  262. });
  263. }else {
  264. //支付子订单费用
  265. this.$api.trade({
  266. tradeNo: this.tradeNo,
  267. password: ''
  268. }).then((res)=>{
  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. })
  277. }
  278. },
  279. payItem(num){
  280. console.log(this.userInfo.balance*1,this.appointmentOrder.totalAmount*1)
  281. if (this.userInfo.balance*1 < this.appointmentOrder.totalAmount*1){
  282. return
  283. }
  284. this.curServiceTab = num
  285. },
  286. closePayPopup(){
  287. this.$refs.popup.close()
  288. },
  289. //一键支付子订单
  290. openPay(order,number){
  291. console.log(order)
  292. console.log(number)
  293. this.openType=number
  294. this.appointmentOrder = order
  295. this.$api.oneClickPay({
  296. orderId:order.orderId
  297. }).then(res=>{
  298. this.tradeNo = res.data.data.tradeNo
  299. this.$refs.popup.open()
  300. })
  301. },
  302. commonGeneralOrder(){
  303. uni.showLoading({
  304. title: '加载中'
  305. });
  306. let that =this
  307. if (this.curServiceTab===1){
  308. // this.$refs.popup.close()
  309. // that.password = ''
  310. // this.$refs.passwordPopup.open()
  311. this.balancePay()
  312. }else {
  313. if (this.openType == 2){
  314. //支付预约费用
  315. this.wechatPay()
  316. }else{
  317. //支付子订单费用
  318. this.$api.wechatPayTradeNo({tradeNo:this.tradeNo}).then(res=>{
  319. var param = res.data.data;
  320. uni.requestPayment({
  321. appId: param.appid,
  322. timeStamp: param.timestamp+"",
  323. nonceStr: param.noncestr,
  324. package: "prepay_id="+param.prepayid,
  325. signType: "RSA",
  326. paySign: param.sign,
  327. success: res => {
  328. uni.hideLoading();
  329. uni.showToast({
  330. title: '支付成功!'
  331. });
  332. that.$refs.popup.close()
  333. that.$refs.MescrollItem[that.tabIndex].downCallback()
  334. that.getUserInfo()
  335. },
  336. fail: res => {
  337. console.log(res)
  338. uni.hideLoading();
  339. uni.showToast({
  340. title: '支付失败',
  341. icon: 'error'
  342. });
  343. that.$refs.popup.close()
  344. that.$refs.MescrollItem[that.tabIndex].downCallback()
  345. that.getUserInfo()
  346. }
  347. });
  348. })
  349. }
  350. }
  351. },
  352. getUserInfo() {
  353. let that = this
  354. this.$api.getUserInfo().then(res => {
  355. that.userInfo = res.data.data
  356. uni.setStorageSync('userInfo', res.data.data);
  357. });
  358. },
  359. clickTab(e) {
  360. this.tabIndex = e.index
  361. },
  362. swiperChange(e) {
  363. this.tabIndex = e.detail.current
  364. },
  365. changeTab(currentTab) {
  366. this.currentTab = currentTab
  367. },
  368. }
  369. }
  370. </script>
  371. <style scoped lang="scss">
  372. @import '/common/css/common.css';
  373. @import './index.rpx.scss';
  374. </style>