index.vue 10 KB

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