mescrollUni-item.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <template>
  2. <!--
  3. swiper中的transfrom会使fixed失效,此时用height固定高度;
  4. swiper中无法触发mescroll-mixins.js的onPageScroll和onReachBottom方法,只能用mescroll-uni,不能用mescroll-body
  5. -->
  6. <!-- ref动态生成: 字节跳动小程序编辑器不支持一个页面存在相同的ref (如不考虑字节跳动小程序可固定值为 ref="mescrollRef") -->
  7. <!-- top的高度等于悬浮菜单tabs的高度 -->
  8. <mescroll-uni :ref="'mescrollRef' + i" @init="mescrollInit" :height="height" :down="downOption" @down="downCallback"
  9. :up="upOption" @up="upCallback" @emptyclick="emptyClick">
  10. <view>
  11. <view class="service-order " v-for="(item,index) in list" :key="index">
  12. <view class="store-wrap" >
  13. <view :class="{ 'grayscale': item.forstStatus === '1' }">
  14. <view @click="orderDetail(item)" class="">
  15. <view class="store-list ">
  16. <view class="store-content ">
  17. <view class="content ">
  18. <view class="desc flex-row justify-start ">
  19. <view :class="item.serviceAttribute == 1? 'service-type':'service-mode'">
  20. {{item.serviceAttrDesc}}
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="order-state-name">
  26. <text class="h-text1">{{ item.forstStatus === '1' ? '已冻结' : item.orderStatusDesc }}</text>
  27. </view>
  28. </view>
  29. <view class="order-state ">
  30. <view class="order-num">
  31. <view class="h-order-num">
  32. <image src="/static/index/u217.png" mode=""></image>订单编号:{{ item.orderNo }}
  33. </view>
  34. </view>
  35. </view>
  36. <view class="flex-row justify-between ">
  37. <view class="flex-col detail11 ">
  38. <view class="item-text flex-row">
  39. <u-icon name="/static/order/ud14.png" size="18"></u-icon>
  40. 服务日期:<text class="item-v">{{ item.serviceDate }}</text>
  41. </view>
  42. <view class="item-text flex-row">
  43. <u-icon name="/static/order/ud2.png" size="18"></u-icon>
  44. 服务门店:<text class="item-v">{{ item.storeName }}</text>
  45. </view>
  46. <view class="item-text flex-row">
  47. <u-icon name="/static/order/ud14.png" size="18"></u-icon>
  48. 下单时间:<text class="item-v">{{ item.createTime }}</text>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="flex-row justify-end">
  53. <view class="price" :style="{'padding-right':'40rpx'}" v-if="item.serviceAttribute == 2">
  54. 预约金额:<text class="fontColor"> ¥{{ item.subAmount || 0}}</text>
  55. </view>
  56. <view class="price">
  57. 订单总金额:<text class="fontColor"> ¥{{ item.payAmount || 0}}</text>
  58. <text :style="{'text-decoration':'line-through','margin-left':'15rpx', 'font-size':'20rpx'}">¥{{ item.totalAmount || 0}}</text>
  59. </view>
  60. </view>
  61. </view>
  62. <view class="nav-bar">
  63. <!-- <view class="btn" v-if="!item.canPay && item.orderStatus == 6" @click="orderFinish(item)">-->
  64. <!-- <text>结束订单</text>-->
  65. <!-- </view>-->
  66. <view class="btn" v-if="item.canPay" @click="oneClickPay(item)">
  67. <text>一键付款</text>
  68. </view>
  69. <view class="btn" v-if="item.canCancel" @click="cancelOrder(item)">
  70. <text>取消</text>
  71. </view>
  72. <view @click="appointment(item)" class="btn" v-if="item.orderStatus == 9">
  73. <text>去支付预约费用</text>
  74. </view>
  75. <!-- <view @click="getOrderSign(item)" class="btn" v-else-if="item.orderStatus == 5">-->
  76. <!-- <text>点击查看排号</text>-->
  77. <!-- </view>-->
  78. <view v-if="item.canSignIn" @click="orderSign(item)" class="btn">
  79. <u-icon name="/static/order/saoma.png" color="#2979ff" size="20"></u-icon>
  80. <text>扫码签到</text>
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. <myPay ref="myPay" :blPay="blPay" :orderNo="orderNo" :openType="openType" :selectBlPay="selectBlPay" :balance="userInfo.balance" @payResult="payResult"></myPay>
  88. </mescroll-uni>
  89. </template>
  90. <script>
  91. import myPay from '../../../components/pay/pay';
  92. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  93. import MescrollMoreItemMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mixins/mescroll-more-item.js"
  94. export default {
  95. mixins: [MescrollMixin, MescrollMoreItemMixin], // 注意此处还需使用MescrollMoreItemMixin (必须写在MescrollMixin后面)
  96. components: {
  97. myPay
  98. },
  99. data() {
  100. return {
  101. openType:1,
  102. selectBlPay:true,
  103. blPay:true,
  104. orderNo:'',
  105. userInfo:{},
  106. downOption: {
  107. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  108. },
  109. upOption: {
  110. auto: false, // 不自动加载
  111. // page: {
  112. // num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  113. // size: 10 // 每页数据的数量
  114. // },
  115. noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
  116. empty: {
  117. icon: '/static/imageIcon/empty.png',
  118. tip: '暂无内容', // 提示
  119. // btnText: '去看看'
  120. },
  121. textNoMore: '没有更多了'
  122. },
  123. list: [],
  124. }
  125. },
  126. props: {
  127. i: Number, // 每个tab页的专属下标 (除了支付宝小程序必须在这里定义, 其他平台都可不用写, 因为已在MescrollMoreItemMixin定义)
  128. index: { // 当前tab的下标 (除了支付宝小程序必须在这里定义, 其他平台都可不用写, 因为已在MescrollMoreItemMixin定义)
  129. type: Number,
  130. default () {
  131. return 0
  132. }
  133. },
  134. dataTime: {
  135. type: String,
  136. default () {
  137. return ''
  138. }
  139. },
  140. tabs: { // 为了请求数据,演示用,可根据自己的项目判断是否要传
  141. type: Array,
  142. default () {
  143. return []
  144. }
  145. },
  146. height: [Number, String], // mescroll的高度
  147. },
  148. watch: {
  149. },
  150. created() {
  151. this.userInfo = uni.getStorageSync('userInfo')
  152. },
  153. methods: {
  154. payResult(e){
  155. if (e.payResult){
  156. uni.showToast({
  157. icon: 'success',
  158. duration: 2000,
  159. title: '付款成功'
  160. });
  161. }
  162. this.downCallback()
  163. this.getUserInfo()
  164. },
  165. orderSign(e){
  166. let that = this
  167. uni.scanCode({
  168. onlyFromCamera: true,
  169. hideAlbum: true,
  170. success: function (res) {
  171. let result = JSON.parse(res.result)
  172. that.$api.orderSign({
  173. orderId:e.orderId,
  174. storeId:result.storeId,
  175. timestamp:result.timestamp
  176. }).then(res1=>{
  177. uni.showToast({
  178. icon: 'success',
  179. duration: 2000,
  180. title: '签到成功'
  181. });
  182. })
  183. }
  184. });
  185. },
  186. orderFinish(item){
  187. this.$api.orderFinish(item.orderNo).then((res)=>{
  188. uni.$u.toast('操作成功')
  189. this.downCallback()
  190. })
  191. },
  192. getOrderSign(order){
  193. this.$emit('serialNumber',order)
  194. },
  195. appointment(order){
  196. //支付预约费用
  197. this.blPay = false
  198. this.orderNo = order.subOrderNo
  199. this.openType = 1
  200. this.$refs.myPay.openPopup()
  201. },
  202. oneClickPay(order){
  203. //支付订单费用
  204. this.blPay = true
  205. this.orderNo = order.orderNo
  206. this.openType = 2
  207. if (this.userInfo.balance *1 > order.payAmount *1){
  208. this.selectBlPay = true
  209. }else {
  210. this.selectBlPay = false
  211. }
  212. this.$refs.myPay.openPopup()
  213. },
  214. scanCodeOrder(item){
  215. let that = this
  216. uni.scanCode({
  217. scanType: ['qrCode'],
  218. success: function (res) {
  219. let json = JSON.parse(res.result)
  220. if(json.storeId != item.storeId){
  221. uni.showToast({
  222. icon: 'error',
  223. duration: 3000,
  224. title: '请扫描订单门店二维码'
  225. });
  226. return
  227. }
  228. uni.navigateTo({
  229. url:'/orderPages/serviceItems/index?serviceStationId='+ json.stationId + '&orderId='+item.orderId + '&serviceObjectId=' + item.serviceObjectId
  230. })
  231. },
  232. })
  233. },
  234. /*下拉刷新的回调 */
  235. downCallback() {
  236. // 这里加载你想下拉刷新的数据, 比如刷新轮播数据
  237. // loadSwiper();
  238. // 下拉刷新的回调,默认重置上拉加载列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )
  239. this.mescroll.resetUpScroll()
  240. },
  241. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  242. upCallback(page) {
  243. let status = this.index
  244. if (this.index === 3){
  245. status = 4
  246. }
  247. //联网加载数据
  248. let httpData = {
  249. pageNum: page.num,
  250. pageSize: 10,
  251. orderType:'SERVICE',
  252. status:status
  253. }
  254. this.$api.getOrderList(httpData).then((res) => {
  255. //联网成功的回调,隐藏下拉刷新和上拉加载的状态;
  256. this.mescroll.endSuccess(res.data.rows.length, res.data.rows.length === 10);
  257. //设置列表数据
  258. if (page.num === 1) this.list = []; //如果是第一页需手动制空列表
  259. this.list = this.list.concat(res.data.rows); //追加新数据
  260. console.log(this.list)
  261. }).catch((err) => {
  262. //联网失败, 结束加载
  263. this.mescroll.endErr();
  264. })
  265. },
  266. getUserInfo() {
  267. this.$api.getUserInfo().then(res => {
  268. this.userInfo = res.data.data
  269. uni.setStorageSync('userInfo', res.data.data)
  270. })
  271. },
  272. //点击空布局按钮的回调
  273. emptyClick() {
  274. uni.showToast({
  275. title: '点击了按钮,具体逻辑自行实现'
  276. })
  277. },
  278. // 搜索
  279. doSearch() {
  280. this.list = []; // 先清空列表,显示加载进度
  281. this.mescroll.resetUpScroll();
  282. },
  283. cancelOrder(item){
  284. uni.showModal({
  285. content: '请确认是否取消订单!',
  286. success: function (res) {
  287. if (res.confirm) {
  288. let that = this
  289. this.$api.cancelOrder({
  290. orderId:item.orderId
  291. }).then(res=>{
  292. that.downCallback()
  293. that.$api.getUserInfo().then( res=> {
  294. uni.setStorageSync('userInfo', res.data.data);
  295. });
  296. })
  297. } else if (res.cancel) {
  298. console.log('用户点击取消');
  299. }
  300. }.bind(this)
  301. })
  302. },
  303. orderDetail(item) {
  304. uni.navigateTo({
  305. url:'/orderPages/orderDetail/index?id='+ item.orderId
  306. })
  307. }
  308. }
  309. }
  310. </script>
  311. <style>
  312. @import '/common/css/common.css';
  313. @import './index.rpx.css';
  314. </style>