index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <!-- 菜单悬浮的原理: 通过给菜单添加position:sticky实现, 用法超简单, 仅APP端的低端机不兼容 https://caniuse.com/#feat=css-sticky -->
  2. <template>
  3. <view>
  4. <!-- 对于mescroll-body: 需设置:sticky="true", 此应避免在mescroll-body标签前面加其他非定位的元素, 否则下拉区域会被挤出, 无法会隐藏.-->
  5. <!-- 对于mescroll-uni: 则无需设置:sticky="true", 无其他限制和要求 -->
  6. <!-- sticky吸顶悬浮的菜单, 父元素必须是 mescroll -->
  7. <view class="sticky-tabs">
  8. <me-tabs v-model="tabIndex" nameKey='title' :tabs="tabs" @change="tabChange"></me-tabs>
  9. </view>
  10. <mescroll-body :sticky="true" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
  11. <!-- 数据列表 -->
  12. <view class="margin-lr-sm margin-top-16 padding-sm bg radius" v-for="(item,index) in goods" :key='index'
  13. @click="bindtakeDetail(item.ordersId)">
  14. <view class="flex justify-between">
  15. <view class="text-blue">{{item.statusName}}</view>
  16. <view class="text-white">{{item.createTime}}</view>
  17. </view>
  18. <view class=" u-flex u-p-t-30">
  19. <view class="u-m-r-10">
  20. <!-- <u-avatar :src="item.homepageImg" mode="square" size="100"></u-avatar> -->
  21. <!-- <u-avatar :src="order.user.avatar" size="68"></u-avatar> -->
  22. <image :src="item.homepageImg" style="width: 140rpx;height: 140rpx;"></image>
  23. </view>
  24. <view class="u-flex-1 text-white margin-left-xs">
  25. <view class="text-30 text-bold u-line-1" style="width: 500rpx;">{{item.myLevel}}</view>
  26. <!-- <view class="u-font-16 text-bold">标题</view> -->
  27. <view class="u-font-14 margin-top-xs u-tips-color flex justify-between">
  28. <view class="text-white">
  29. <view style="display: inline-flex;">
  30. <view class="margin-top-xs text-white text-df"
  31. v-for="(item,index) in item.gameName " :key="index"
  32. style="margin-right: 10rpx;">{{item}}</view>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="text-white text-right margin-top-sm">
  37. 实收: <text class="text-lg">{{item.oldMoney*item.orderNumber}}元</text>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="margin-top-sm" v-if="item.remarks">
  42. 备注:<text class="text-red">{{item.remarks}}</text>
  43. </view>
  44. <view class="flex justify-end u-p-t-20">
  45. <u-button v-if="item.state == 1" :custom-style="customStyle" shape="circle" :plain="true"
  46. @click="cancelOrder(item,3)">拒接接单</u-button>
  47. <!-- <u-button v-if="item.state == 3" :custom-style="customStyle" shape="circle" :plain="true" @click="delOrder(item)">拒接接单</u-button> -->
  48. <u-button v-if="item.state == 1" :custom-style="customStyle1" shape="circle" :plain="true"
  49. @click="cancelOrder(item,2)">完成接单</u-button>
  50. <u-button :custom-style="customStyle" shape="circle" :plain="true" @click="clickItem(item)">联系TA
  51. </u-button>
  52. </view>
  53. </view>
  54. <empty v-if="goods.length == 0"></empty>
  55. </mescroll-body>
  56. </view>
  57. </template>
  58. <script>
  59. import MescrollMixin from "@/components/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  60. import mescrollBody from "@/components/mescroll-uni/components/mescroll-body/mescroll-body.vue";
  61. import meTabs from "@/components/mescroll-uni/me-tabs/me-tabs.vue";
  62. import empty from '../../components/empty.vue'
  63. export default {
  64. mixins: [MescrollMixin], // 使用mixin
  65. components: {
  66. mescrollBody,
  67. meTabs,
  68. empty
  69. },
  70. data() {
  71. return {
  72. goods: [], // 数据列表
  73. tabs: [{
  74. title: '全部',
  75. status: ''
  76. }, {
  77. title: '进行中',
  78. status: '1'
  79. }, {
  80. title: '已完成',
  81. status: '2'
  82. },
  83. {
  84. title: '已拒绝',
  85. status: '3'
  86. }
  87. ],
  88. tabIndex: 0, // tab下标
  89. game: [],
  90. page: 1,
  91. limit: 10,
  92. userId: 0,
  93. status: 1,
  94. nickName: '',
  95. avatar: '',
  96. customStyle: {
  97. color: '#999999',
  98. border: '2rpx solid #999999',
  99. // backgroundColor: '#1E1F31',
  100. border: "8rpx",
  101. width: '180rpx',
  102. height: '54rpx',
  103. margin: "0 0 0 20rpx"
  104. },
  105. customStyle1: {
  106. color: '#557EFD',
  107. border: '2rpx solid #557EFD',
  108. // backgroundColor: '#1E1F31',
  109. border: "8rpx",
  110. width: '180rpx',
  111. height: '54rpx',
  112. margin: "0 0 0 20rpx"
  113. },
  114. }
  115. },
  116. onLoad() {
  117. this.$queue.showLoading("加载中...");
  118. this.userId = uni.getStorageSync('userId')
  119. this.nickName = uni.getStorageSync('nickName')
  120. },
  121. onShow() {
  122. this.downCallback()
  123. this.upCallback(this.page)
  124. },
  125. methods: {
  126. // 接单详情
  127. bindtakeDetail(e) {
  128. console.log(e)
  129. let id = e
  130. uni.navigateTo({
  131. url: './takeDetail?id=' + id
  132. })
  133. },
  134. /*下拉刷新的回调 */
  135. downCallback() {
  136. // 这里加载你想下拉刷新的数据, 比如刷新轮播数据
  137. // loadSwiper();
  138. // 下拉刷新的回调,默认重置上拉加载列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )
  139. this.mescroll.resetUpScroll()
  140. },
  141. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  142. upCallback(page) {
  143. let curTab = this.tabs[this.tabIndex].status
  144. let data = {
  145. status: curTab,
  146. page: page.num,
  147. limit: page.size
  148. }
  149. this.$Request.get('/app/orders/selectMyTakeOrders', data).then(res => {
  150. uni.hideLoading();
  151. this.mescroll.endBySize(res.data.list.length, res.data.totalCount)
  152. if (page.num == 1) this.goods = []; //如果是第一页需手动制空列表
  153. res.data.list.forEach(ret => {
  154. switch (ret.state) {
  155. case 0:
  156. ret.statusName = '待接单'
  157. break;
  158. case 1:
  159. ret.statusName = '进行中'
  160. break;
  161. case 2:
  162. ret.statusName = '已完成'
  163. break;
  164. case 3:
  165. ret.statusName = '已拒绝'
  166. break;
  167. }
  168. })
  169. this.goods = [...this.goods, ...res.data.list]; //追加新数据
  170. for (let i = 0; i < this.goods.length; i++) {
  171. this.goods[i].gameName = this.goods[i].gameName.split(",");
  172. }
  173. this.mescroll.endSuccess(res.data.total.length); // 隐藏加载状态栏
  174. }).catch(() => {
  175. //联网失败, 结束加载
  176. this.mescroll.endErr();
  177. });
  178. },
  179. // 切换菜单
  180. tabChange() {
  181. this.goods = []; // 置空列表,显示加载进度条
  182. this.mescroll.resetUpScroll()
  183. },
  184. // 取消订单
  185. cancelOrder(e, status) {
  186. let that = this
  187. let content = ''
  188. if (status == 3) {
  189. content = '确定拒绝接单吗?'
  190. } else if (status == 2) {
  191. content = '确定订单已经完成吗?如果未完成,客户投诉将采取封号处理'
  192. }
  193. uni.showModal({
  194. title: '提示',
  195. content: content,
  196. success: function(res) {
  197. if (res.confirm) {
  198. let data = {
  199. id: e.ordersId,
  200. status
  201. }
  202. that.$Request.get('/app/orders/cancelOrder', data).then(res => {
  203. if (res.code == 0) {
  204. that.mescroll.resetUpScroll()
  205. }
  206. })
  207. }
  208. },
  209. })
  210. },
  211. //
  212. clickItem: function(options) {
  213. let data = {
  214. userId: this.userId,
  215. focusedUserId: options.ordersUserId
  216. }
  217. this.$Request.postJson('/app/chat/insertChatConversation ', data).then(res => {
  218. if (res.code == 0) {
  219. let id = this.userId == res.data.userId ? res.data.focusedUserId : this.userId
  220. uni.navigateTo({
  221. url: '/pages/msg/im?chatConversationId=' + res.data.chatConversationId +
  222. '&byUserId=' + id
  223. })
  224. }
  225. })
  226. },
  227. goNav(e) {
  228. uni.navigateTo({
  229. url: e
  230. })
  231. }
  232. }
  233. }
  234. </script>
  235. <style lang="scss">
  236. /*
  237. sticky生效条件:
  238. 1、父元素不能overflow:hidden或者overflow:auto属性。(mescroll-body设置:sticky="true"即可, mescroll-uni本身没有设置overflow)
  239. 2、必须指定top、bottom、left、right4个值之一,否则只会处于相对定位
  240. 3、父元素的高度不能低于sticky元素的高度
  241. 4、sticky元素仅在其父元素内生效,所以父元素必须是 mescroll
  242. */
  243. .sticky-tabs {
  244. z-index: 990;
  245. position: sticky;
  246. top: var(--window-top);
  247. // background-color: #fff;
  248. }
  249. // 使用mescroll-uni,则top为0
  250. .mescroll-uni,
  251. /deep/.mescroll-uni {
  252. .sticky-tabs {
  253. top: 0;
  254. }
  255. }
  256. .demo-tip {
  257. padding: 18upx;
  258. font-size: 24upx;
  259. text-align: center;
  260. }
  261. page {
  262. background-color: #F7F7F7;
  263. }
  264. .bg {
  265. background-color: #FFFFFF;
  266. }
  267. .tabber {
  268. width: 100%;
  269. background: #ffffff;
  270. position: fixed;
  271. bottom: 0;
  272. left: 0;
  273. right: 0;
  274. justify-content: flex-end;
  275. height: 127rpx;
  276. }
  277. </style>