index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. <!-- 菜单悬浮的原理: 通过给菜单添加position:sticky实现, 用法超简单, 仅APP端的低端机不兼容 https://caniuse.com/#feat=css-sticky -->
  2. <template>
  3. <view>
  4. <view class="sticky-tabs">
  5. <u-tabs :list="tabs" :is-scroll="true" :current="tabIndex" @change="tabChange" active-color="#000000"
  6. inactive-color="#999999"></u-tabs>
  7. </view>
  8. <!-- 数据列表 -->
  9. <view v-if="goods.length > 0" class="margin-sm bg padding-tb-sm" v-for="(item,index) in goods" :key='index'
  10. @click="goNav('/my/order/pay?ordersId='+item.ordersId)" style="border-radius: 24rpx;">
  11. <view class="flex justify-between padding-lr-sm ">
  12. <view class="flex align-center">
  13. <image src="../../static/logo.png" style="width: 48rpx;height: 48rpx;border-radius: 50%;">
  14. </image>
  15. <view class="margin-left-xs ">{{item.artificerName}}</view>
  16. </view>
  17. <view class="theme-color" v-if="item.status ==1">待付款</view>
  18. <view class="theme-color" v-if="item.status ==2">待服务</view>
  19. <view class="theme-color" v-if="item.status ==3">待评价</view>
  20. <view class="theme-color" v-if="item.status ==5">已完成</view>
  21. <view class="theme-color" v-if="item.status ==6">服务中</view>
  22. <view class="theme-color" v-if="item.status ==7">技师出发</view>
  23. <view class="theme-color" v-if="item.status ==8">技师到达</view>
  24. <view class="theme-color" v-if="item.status ==4" style="color: #999999;">已取消</view>
  25. <!-- <view class="u-tips-color">{{item.createTime}}</view> -->
  26. </view>
  27. <view class="margin-top-sm" style="width: 100%;height: 1rpx;background: #EEEEEE;"></view>
  28. <view class=" u-flex u-p-t-30 padding-lr-sm">
  29. <view class="u-m-r-10">
  30. <u-avatar
  31. :src="(item.ordersMassageList && item.ordersMassageList.length > 0 && item.ordersMassageList[0].massageType && item.ordersMassageList[0].massageType.massageImg)?item.ordersMassageList[0].massageType.massageImg: '../../static/logo.png'"
  32. mode="square" size="100">
  33. </u-avatar>
  34. </view>
  35. <view class="u-flex-1 margin-left-xs">
  36. <view class="u-font-18 text-bold u-line-1" style="width: 560rpx;">
  37. <view class=" text-lg "
  38. v-if="item.ordersMassageList && item.ordersMassageList.length > 0 && item.ordersMassageList[0].massageType && item.ordersMassageList[0].massageType.title"
  39. style="margin-top: 0rpx;display: inline-block;width: 470rpx; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">
  40. {{item.ordersMassageList[0].massageType.title}}
  41. </view>
  42. </view>
  43. <view class="u-font-14 margin-top-xs u-tips-color flex justify-between">
  44. 预约时间:{{item.serveTime}}
  45. </view>
  46. </view>
  47. </view>
  48. <view class="flex u-p-t-20 justify-between align-center padding-lr-sm">
  49. <view class=" flex-sub ">
  50. 实付:<text class="text-df" style="color: #F24E4E;">¥</text><text class="text-xl text-bold"
  51. style="color: #F24E4E;font-size: 40rpx;">{{item.sumMoney}}</text>
  52. </view>
  53. <view class="flex text-right">
  54. <u-button
  55. v-if="(item.status == 1 || item.status == 2 || item.status == 7 || item.status == 8) && yhqxSel != '否'"
  56. :custom-style="customStyle" shape="circle" :plain="true"
  57. @click="cancelOrder(item)">取消订单</u-button>
  58. <u-button v-if="item.status == 1" :custom-style="customStyle1" shape="circle" :plain="true"
  59. @click="goNav('/my/order/pay?ordersId='+item.ordersId)">去支付</u-button>
  60. <u-button v-if="item.status == 2" :custom-style="customStyle1" shape="circle" :plain="true"
  61. @click="goNav('/my/order/pay?ordersId='+item.ordersId)">查看详情</u-button>
  62. <!-- <u-button v-if="item.status == 6" :custom-style="customStyle" shape="circle" :plain="true"
  63. @click="cancel(item)">订单完成</u-button> -->
  64. <!-- <u-button v-if="item.state == 2" :custom-style="customStyle" shape="circle" :plain="true" @click="goNav('/my/order/complain?id='+item.ordersId)" >去投诉</u-button> -->
  65. <u-button v-if="item.status == 3" :custom-style="customStyle1" shape="circle" :plain="true"
  66. @click="goNav('/my/order/feedback?artificerId='+item.artificerId+ '&ordersId='+item.ordersId)">
  67. 去评价
  68. </u-button>
  69. <u-button v-if="(item.status == 4 || item.status == 5) && userDeletaSel != '否'"
  70. :custom-style="customStyle" shape="circle" :plain="true" @click="delOrder(item)">删除订单</u-button>
  71. </view>
  72. </view>
  73. </view>
  74. <empty v-if="goods.length == 0"></empty>
  75. </view>
  76. </template>
  77. <script>
  78. import MescrollMixin from "@/components/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  79. import mescrollBody from "@/components/mescroll-uni/components/mescroll-body/mescroll-body.vue";
  80. import meTabs from "@/components/mescroll-uni/me-tabs/me-tabs.vue";
  81. import empty from '@/components/empty.vue'
  82. export default {
  83. mixins: [MescrollMixin], // 使用mixin
  84. components: {
  85. mescrollBody,
  86. meTabs,
  87. empty
  88. },
  89. data() {
  90. return {
  91. goods: [], // 数据列表
  92. game: [],
  93. tabs: [{
  94. name: '全部',
  95. status: '0'
  96. }, {
  97. name: '待支付',
  98. status: '1'
  99. }, {
  100. name: '待服务',
  101. status: '2'
  102. }, {
  103. name: '技师出发',
  104. status: '7'
  105. }, {
  106. name: '技师到达',
  107. status: '8'
  108. }, {
  109. name: '服务中',
  110. status: '6'
  111. }, {
  112. name: '待评价',
  113. status: '3'
  114. }, {
  115. name: '已取消',
  116. status: '4'
  117. }, {
  118. name: '已完成',
  119. status: '5'
  120. }],
  121. tabIndex: 0, // tab下标
  122. page: 1,
  123. limit: 10,
  124. userId: 0,
  125. status: 1,
  126. nickName: '',
  127. avatar: '',
  128. customStyle: {
  129. color: '#999999',
  130. border: '4rpx solid #999999',
  131. border: "8rpx",
  132. width: '180rpx',
  133. height: '60rpx',
  134. margin: "0 0 0 20rpx",
  135. fontSize: '26rpx'
  136. },
  137. customStyle1: {
  138. color: '#FFFFFF',
  139. backgroundColor: '#FF6E98',
  140. border: "8rpx",
  141. width: '200rpx',
  142. height: '64rpx',
  143. margin: "0 0 0 20rpx",
  144. fontSize: '26rpx'
  145. },
  146. yhqxSel: '否',
  147. userDeletaSel: '否'
  148. // customStyle: {
  149. // color: '#1789FD',
  150. // backgroundColor: '#1E1F31',
  151. // border: "8rpx",
  152. // width: '180rpx',
  153. // height: '54rpx',
  154. // margin: "0 0 0 20rpx"
  155. // }
  156. }
  157. },
  158. onLoad() {
  159. this.userId = uni.getStorageSync('userId')
  160. this.nickName = uni.getStorageSync('nickName')
  161. },
  162. onShow() {
  163. this.userDeletaSel = this.$queue.getData('userDeletaSel');
  164. this.yhqxSel = this.$queue.getData("yhqxSel");
  165. let SelectIndex = this.$queue.getData('SelectIndex');
  166. if (SelectIndex) {
  167. this.tabIndex = SelectIndex;
  168. this.$queue.remove('SelectIndex')
  169. }
  170. let token = this.$queue.getData('token');
  171. if (token) {
  172. uni.showLoading({
  173. title: '加载中...'
  174. })
  175. this.getOrderList()
  176. } else {
  177. uni.navigateTo({
  178. url: '/pages/public/login'
  179. });
  180. }
  181. },
  182. methods: {
  183. //获取列表数据
  184. getOrderList() {
  185. let curTab = this.tabs[this.tabIndex].status
  186. let data = {
  187. status: curTab,
  188. page: this.page,
  189. limit: this.limit
  190. }
  191. this.$Request.get('/app/artificer/selectOrdersList', data).then(res => {
  192. if (res.code == 0) {
  193. uni.hideLoading();
  194. console.log(res)
  195. if (this.page == 1) this.goods = []; //如果是第一页需手动制空列表
  196. this.goods = [...this.goods, ...res.data.list]; //追加新数据
  197. // this.goods.forEach(ret => {
  198. // switch (ret.status) {
  199. // case '1':
  200. // ret.statusName = '待付款'
  201. // break;
  202. // case '2':
  203. // ret.statusName = '进行中'
  204. // break;
  205. // case '3':
  206. // ret.statusName = '已评价'
  207. // break;
  208. // case '4':
  209. // ret.statusName = '已取消'
  210. // break;
  211. // case '5':
  212. // ret.statusName = '已完成'
  213. // break;
  214. // }
  215. // })
  216. }
  217. }).catch(() => {
  218. //联网失败, 结束加载
  219. });
  220. },
  221. // 切换菜单
  222. tabChange(index) {
  223. uni.showLoading({
  224. title: '加载中...'
  225. })
  226. this.tabIndex = index
  227. // this.goods = []; // 置空列表,显示加载进度条
  228. this.page = 1
  229. this.getOrderList()
  230. },
  231. // 取消订单
  232. cancelOrder(e) {
  233. let contentName = '';
  234. let closeKC = this.$queue.getData('closeKC');
  235. if (e.status == 7 || e.status == 8 && closeKC) {
  236. let money = parseFloat(parseFloat(e.price) * parseFloat(closeKC)).toFixed(2);
  237. contentName = '取消订单将扣除' + money + '元的手续费,并且车费将全部扣除!';
  238. }
  239. let that = this
  240. uni.showModal({
  241. title: '温馨提示',
  242. content: '是否确认取消订单?' + contentName,
  243. success: function(res) {
  244. if (res.confirm) {
  245. let data = {
  246. ordersId: e.ordersId
  247. }
  248. that.$queue.showLoading('取消中...')
  249. that.$Request.post('/app/artificer/deleteOrders', data).then(res => {
  250. uni.hideLoading();
  251. if (res.code == 0) {
  252. that.page = 1
  253. that.getOrderList()
  254. } else {
  255. that.$queue.showToast(res.msg);
  256. }
  257. })
  258. } else if (res.cancel) {
  259. console.log('用户点击取消');
  260. }
  261. }
  262. });
  263. },
  264. /*下拉刷新的回调 */
  265. downCallback() {
  266. // 这里加载你想下拉刷新的数据, 比如刷新轮播数据
  267. // loadSwiper();
  268. // 下拉刷新的回调,默认重置上拉加载列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )
  269. this.mescroll.resetUpScroll()
  270. this.page = 1;
  271. this.getOrderList();
  272. },
  273. // 完成订单
  274. cancel(e) {
  275. let that = this
  276. uni.showModal({
  277. title: '提示',
  278. content: '确认完成订单吗?',
  279. success: function(res) {
  280. if (res.confirm) {
  281. let data = {
  282. ordersId: e.ordersId,
  283. }
  284. that.$queue.showLoading('提交中...')
  285. that.$Request.post('/app/artificer/accomplishOrders', data).then(res => {
  286. uni.hideLoading();
  287. if (res.code == 0) {
  288. that.page = 1
  289. that.getOrderList()
  290. } else {
  291. that.$queue.showToast(res.msg);
  292. }
  293. })
  294. } else if (res.cancel) {
  295. console.log('用户点击取消');
  296. }
  297. }
  298. });
  299. },
  300. //删除
  301. delOrder(e) {
  302. let that = this
  303. uni.showModal({
  304. title: '提示',
  305. content: '确定删除订单吗?',
  306. success: function(res) {
  307. if (res.confirm) {
  308. let data = {
  309. ordersId: e.ordersId,
  310. }
  311. that.$queue.showLoading('删除中...')
  312. that.$Request.post('/app/artificer/removeOrders', data).then(res => {
  313. uni.hideLoading();
  314. if (res.code == 0) {
  315. that.$queue.showToast('删除成功!');
  316. setTimeout(d => {
  317. that.page = 1
  318. that.getOrderList()
  319. }, 1500)
  320. } else {
  321. that.$queue.showToast(res.msg);
  322. }
  323. })
  324. } else if (res.cancel) {
  325. console.log('用户点击取消');
  326. }
  327. }
  328. });
  329. },
  330. goNav(url) {
  331. uni.navigateTo({
  332. url
  333. })
  334. }
  335. },
  336. onReachBottom: function() {
  337. this.page = this.page + 1;
  338. this.getOrderList();
  339. if (this.totalCount == this.orderList.length) {
  340. uni.showToast({
  341. title: '已经到底了~',
  342. icon: 'none'
  343. })
  344. }
  345. },
  346. onPullDownRefresh: function() {
  347. this.page = 1;
  348. this.getOrderList();
  349. setTimeout(d => {
  350. uni.stopPullDownRefresh();
  351. }, 2000)
  352. },
  353. }
  354. </script>
  355. <style lang="scss">
  356. page {
  357. background: #F5F5F5;
  358. }
  359. .theme-color{
  360. color: $uni-color-primary;
  361. }
  362. /*
  363. sticky生效条件:
  364. 1、父元素不能overflow:hidden或者overflow:auto属性。(mescroll-body设置:sticky="true"即可, mescroll-uni本身没有设置overflow)
  365. 2、必须指定top、bottom、left、right4个值之一,否则只会处于相对定位
  366. 3、父元素的高度不能低于sticky元素的高度
  367. 4、sticky元素仅在其父元素内生效,所以父元素必须是 mescroll
  368. */
  369. .sticky-tabs {
  370. z-index: 990;
  371. position: sticky;
  372. top: var(--window-top);
  373. // background-color: #fff;
  374. }
  375. // 使用mescroll-uni,则top为0
  376. .mescroll-uni,
  377. /deep/.mescroll-uni {
  378. .sticky-tabs {
  379. top: 0;
  380. }
  381. }
  382. .demo-tip {
  383. padding: 18upx;
  384. font-size: 24upx;
  385. text-align: center;
  386. }
  387. page {
  388. background-color: #F7F7F7;
  389. }
  390. .bg {
  391. background-color: #FFFFFF;
  392. }
  393. </style>