index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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" v-if="currentTab === 0">
  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}" v-if="currentTab === 0">
  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" @openPay="openPay">
  28. </mescroll-item>
  29. </view>
  30. </swiper-item>
  31. </swiper>
  32. </view>
  33. <view class="product-order" v-if="currentTab === 1">
  34. <!-- Tab 2 内容 -->
  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.isOverNo !== '否'" 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. num: 0,
  140. title: 'Hello',
  141. tabIndex: 0,
  142. tabBarIndex:3,
  143. currentTab: 0,
  144. currentServiceTab: 'orderTab1',
  145. tabList: [{
  146. name: '全部'
  147. }, {
  148. name: '当前订单'
  149. }, {
  150. name: '待付款'
  151. }, {
  152. name: '已完成'
  153. }],
  154. windowHeight: '',
  155. userInfo:{},
  156. curServiceTab:1,
  157. tradeNo:'',
  158. password:''
  159. }
  160. },
  161. onLoad() {
  162. uni.hideTabBar({
  163. animation: false
  164. })
  165. let sysInfo = uni.getSystemInfoSync()
  166. this.windowHeight = sysInfo.windowHeight - 44 + 'px' //除标题栏栏外的屏幕可用高度
  167. this.$off()
  168. this.$on('orderListIndex',this.listenerIndex)
  169. },
  170. onShow(){
  171. if (uni.getStorageSync('orderListIndex')){
  172. this.tabIndex = uni.getStorageSync('orderListIndex')
  173. }
  174. uni.removeStorageSync('orderListIndex');
  175. },
  176. methods: {
  177. balancePay(){
  178. let that = this;
  179. if(this.password.length< 6 ){
  180. uni.showToast({
  181. title: "交易密码不能小于6位"
  182. })
  183. return ;
  184. }
  185. this.$refs.passwordPopup.close()
  186. // 用户信息
  187. this.$api.trade({
  188. tradeNo: this.tradeNo,
  189. password: this.password
  190. }).then((res)=>{
  191. uni.switchTab({
  192. url:'/pages/order/index'
  193. })
  194. }).catch(() =>{
  195. uni.showToast({
  196. title: "操作失败"
  197. })
  198. });
  199. },
  200. payItem(num){
  201. if (this.userInfo.balance < this.price){
  202. return
  203. }
  204. this.curServiceTab = num
  205. },
  206. closePayPopup(){
  207. this.$refs.popup.close()
  208. },
  209. openPay(order){
  210. this.$api.oneClickPay({
  211. orderId:order.orderId
  212. }).then(res=>{
  213. this.tradeNo = res.data.data.tradeNo
  214. this.$refs.popup.open()
  215. })
  216. },
  217. commonGeneralOrder(){
  218. let that =this
  219. if (this.curServiceTab===1){
  220. this.$refs.popup.close()
  221. this.$refs.passwordPopup.open()
  222. }else {
  223. this.$api.wechatPayTradeNo({tradeNo:this.tradeNo}).then(res=>{
  224. var param = res.data.data;
  225. uni.requestPayment({
  226. appId: param.appid,
  227. timeStamp: param.timestamp+"",
  228. nonceStr: param.noncestr,
  229. package: "prepay_id="+param.prepayid,
  230. signType: "RSA",
  231. paySign: param.sign,
  232. success: res => {
  233. uni.showToast({
  234. title: '支付成功!'
  235. });
  236. that.$refs.popup.close()
  237. that.$refs.MescrollItem[that.tabIndex].downCallback()
  238. },
  239. fail: res => {
  240. console.log(res)
  241. uni.showModal({
  242. content: '支付失败',
  243. showCancel: false
  244. });
  245. that.$refs.popup.close()
  246. that.$refs.MescrollItem[that.tabIndex].downCallback()
  247. }
  248. });
  249. }).catch(() =>{
  250. uni.showToast({
  251. title: "操作失败"
  252. })
  253. });
  254. }
  255. },
  256. clickTab(e) {
  257. this.tabIndex = e.index
  258. },
  259. swiperChange(e) {
  260. this.tabIndex = e.detail.current
  261. },
  262. changeTab(currentTab) {
  263. this.currentTab = currentTab
  264. },
  265. }
  266. }
  267. </script>
  268. <style scoped lang="scss">
  269. @import '/common/css/common.css';
  270. @import './index.rpx.scss';
  271. </style>