index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. <template>
  2. <view>
  3. <view class="top-1">
  4. <!-- 状态栏高度 -->
  5. <view :style="{ height: `${statusBarHeight}px` }"></view>
  6. <!-- 导航栏 -->
  7. <view :style="{ height: `${navigationBarHeight}px`,lineHeight: `${navigationBarHeight}px`}" class="order-nav">订单
  8. </view>
  9. <!-- 进行中/历史订单 -->
  10. <view class="status-bar">
  11. <view>
  12. <text :class="isShow==0? 'status-true': 'status-false'" @click="statusClick(0)">进行中</text>
  13. <text :class="isShow==1? 'status-true': 'status-false'" @click="statusClick(1)">历史订单</text>
  14. </view>
  15. </view>
  16. </view>
  17. <!-- 列表数据 -->
  18. <view class="nbox-1" v-if="list.length">
  19. <view class="nbox-2" v-for="(item,index) in list" :key="index">
  20. <view class="container" @click='goOrderDetails(item)'>
  21. <text class="left-text">{{item.merName}}</text>
  22. <view class="right-group">
  23. <text v-if="item.status==1||item.status==2||item.status==3" style="color: #0FBA42;font-size: 23rpx;">制作中</text>
  24. <text v-if="item.status==4" style="color: #FF5500;font-size: 23rpx;">配送中</text>
  25. <image src="/static/img/ic-yx.png" class="image" />
  26. </view>
  27. </view>
  28. <view class="scroll-container" v-for='(ottm,indexs) in item.orderInfoList' :key="indexs" @click='goOrderDetails(item)'>
  29. <view class="item">
  30. <img :src='ottm.image'>
  31. <text>{{ottm.productName}} x{{ottm.payNum}}</text>
  32. </view>
  33. </view>
  34. <view class="dashed-line"></view>
  35. <view style="text-align: right; font-size: 23rpx; color: #141414;padding-right: 20rpx;">
  36. 共{{item.orderInfoList.length}}件,实付 ¥{{ item.payPrice}}元
  37. </view>
  38. <view class="container2">
  39. <text v-if="item.status==1||item.status==2||item.status==3" class="left-text2">商家正在备餐中</text>
  40. <text v-if="item.status==4" class="left-text2">商家备餐完成</text>
  41. <view class="right-group">
  42. <image src="/static/img/ic-iphone1.png" class="image2" />
  43. <text @click="makePhoneCall(item)" style="color: #141414;font-size: 21rpx;">联系商家</text>
  44. <view style="display: inline-block; width: 2rpx; height: 42rpx;border: 2rpx solid #D5D6DC;"></view>
  45. <!-- 留言字段 -->
  46. <image src="/static/img/ic-message1.png" class="image2" />
  47. <text style="color: #141414;font-size: 21rpx;" @click="modify(item, 1)">留言</text>
  48. </view>
  49. <PriceChange :change="change" :orderInfo="orderInfo" :isRefund="isRefund"
  50. v-on:statusChange="statusChange($event)" v-on:closechange="changeclose($event)" v-on:savePrice="savePrice"
  51. :status="status"></PriceChange>
  52. </view>
  53. </view>
  54. <view class='loadingicon flex-center' :hidden='!loading'>
  55. <text class='loading iconfont icon-jiazai' style="width: auto;"></text>加载更多
  56. </view>
  57. <view class="flex-center no-data-tip" v-if="loadTitle">{{loadTitle}}</view>
  58. </view>
  59. <emptyPage v-else title="暂无订单~" :imgSrc="urlDomain+'crmebimage/presets/noShopper.png'"></emptyPage>
  60. </view>
  61. </template>
  62. <script>
  63. import PriceChange from "./PriceChange/index.vue";
  64. import emptyPage from '@/components/emptyPage.vue'
  65. import {
  66. ProductTypeEnum,
  67. } from "@/enums/productEnums";
  68. import {
  69. userMark,
  70. getOrderList
  71. } from '@/api/order.js';
  72. import {
  73. mapGetters
  74. } from "vuex";
  75. import {
  76. tokenIsExistApi
  77. } from '@/api/api.js';
  78. var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
  79. let app = getApp();
  80. export default {
  81. components: {
  82. emptyPage,
  83. PriceChange
  84. },
  85. data() {
  86. return {
  87. urlDomain: this.$Cache.get("imgHost"),
  88. statusBarHeight: app.globalData.statusBarHeight,
  89. navigationBarHeight: 0,
  90. isShow: 1,
  91. loading: false,
  92. noDataTip: '',
  93. loadTitle: '',
  94. page: 1,
  95. list: [], //订单数据
  96. ProductTypeEnum,
  97. change:false,
  98. orderInfo:{},
  99. status: "",
  100. tokenIsExist: false, //校验token是否有效
  101. }
  102. },
  103. computed: {
  104. ...mapGetters(['isLogin', 'productType', 'globalData', 'bottomNavigationIsCustom']),
  105. },
  106. //下拉刷新
  107. onPullDownRefresh() {
  108. },
  109. onLoad(options) {
  110. this.getTokenIsExist();
  111. let that = this;
  112. //首页数据加载
  113. // this.getIndexConfig();
  114. // #ifdef MP-WEIXIN
  115. // 获取微信胶囊的位置信息 width,height,top,right,left,bottom
  116. const custom = wx.getMenuButtonBoundingClientRect()
  117. // 导航栏高度(标题栏高度) = 胶囊高度 + (顶部距离 - 状态栏高度) * 2
  118. this.navigationBarHeight = custom.height + (custom.top - this.statusBarHeight) * 2
  119. // console.log("导航栏高度:"+this.globalData.navigationBarHeight)
  120. // #endif
  121. },
  122. onShow() {
  123. },
  124. methods: {
  125. //校验token是否有效,true为有效,false为无效
  126. getTokenIsExist() {
  127. tokenIsExistApi().then(res => {
  128. this.tokenIsExist = res.data;
  129. if (this.isLogin && this.tokenIsExist) {
  130. this.getOrderList() //订单列表
  131. }
  132. })
  133. },
  134. modify: function(item, status) {
  135. this.change = true;
  136. this.status = status.toString();
  137. this.orderInfo = item;
  138. },
  139. changeclose: function(msg) {
  140. this.change = msg;
  141. },
  142. async savePrice(opt) {
  143. let that = this,
  144. data = {};
  145. data.orderNo = that.orderInfo.orderNo;
  146. data.remark=opt.remark
  147. if (!data.remark) {
  148. return this.$util.Tips({
  149. title: '请输入备注'
  150. })
  151. }
  152. userMark(data).then(res=>{
  153. if(res.code==200){
  154. this.$util.Tips({
  155. title: '备注成功'
  156. })
  157. this.getOrderList();
  158. this.change = false
  159. }else{
  160. this.$util.Tips({
  161. title:res.message
  162. })
  163. }
  164. })
  165. },
  166. /**
  167. * 去订单详情
  168. */
  169. goOrderDetails: function(item, status) {
  170. if (item.groupBuyRecordStatus === 0) return this.$util.Tips({
  171. title: '拼团中无法查看详情'
  172. });
  173. if (!item.orderNo) return this.$util.Tips({
  174. title: '缺少订单号无法查看订单详情'
  175. });
  176. //虚拟商品
  177. if (item.secondType === this.ProductTypeEnum?.CloudDrive || item.secondType === this.ProductTypeEnum
  178. ?.CardPassword) {
  179. // #ifdef MP
  180. uni.navigateTo({
  181. url: '/pages/goods/virtual_order_details/index?orderNo=' + item.orderNo
  182. })
  183. // #endif
  184. } else {
  185. // #ifdef MP
  186. uni.navigateTo({
  187. url: '/pages/goods/order_details/index?orderNo=' + item.orderNo
  188. })
  189. // #endif
  190. }
  191. },
  192. // 拨打电话
  193. makePhoneCall(item) {
  194. const phoneNumber = item.merPhone; // 替换为商家的电话号码
  195. uni.makePhoneCall({
  196. phoneNumber: phoneNumber,
  197. success() {
  198. console.log('拨打电话成功');
  199. },
  200. fail() {
  201. console.log('拨打电话失败');
  202. }
  203. });
  204. },
  205. // 头部切换
  206. statusClick(index) {
  207. this.isShow = index;
  208. this.list = []
  209. this.page = 1
  210. this.getOrderList() // 订单列表
  211. },
  212. // 订单列表
  213. getOrderList() {
  214. this.loading = true
  215. getOrderList({
  216. limit: 20, //条数
  217. page: this.page, //页码
  218. orderType: this.isShow, //类型订单类型:0-进行中,1-完成
  219. }).then(res => {
  220. console.log('订单列表', res)
  221. if (res.code == 200) {
  222. const list = res.data.list
  223. this.list = this.$util.SplitArray(list, this.list);
  224. if (this.list.length == 0) {
  225. this.loadTitle = ''
  226. this.noDataTip = ' 暂无外卖商家 ';
  227. } else {
  228. this.noDataTip = ''
  229. this.loadTitle = list.length < 20 ? "我也是有底线的~" : '';
  230. }
  231. this.loading = false
  232. this.page += 1
  233. }
  234. }).catch(err => {
  235. this.loading = false
  236. })
  237. }
  238. },
  239. mounted() {
  240. },
  241. }
  242. </script>
  243. <style scoped>
  244. .order-nav {
  245. font-weight: 500;
  246. font-size: 35rpx;
  247. color: #FFFFFF;
  248. background-color: #FF6702;
  249. text-align: center;
  250. }
  251. .no-data-tip {
  252. color: #CCC;
  253. }
  254. .status-bar {
  255. background-color: #FF6702;
  256. text-align: center;
  257. padding: 20rpx;
  258. box-sizing: border-box;
  259. }
  260. .status-bar view {
  261. display: inline-block;
  262. width: 385rpx;
  263. background: #EB5E00;
  264. border-radius: 37rpx;
  265. }
  266. .status-true {
  267. display: inline-block;
  268. width: 192rpx;
  269. padding: 10rpx 0;
  270. background-color: white;
  271. color: #FF6600;
  272. border-radius: 37rpx;
  273. }
  274. .status-false {
  275. display: inline-block;
  276. width: 192rpx;
  277. padding: 10rpx 0;
  278. color: #FFCBA9;
  279. border-radius: 37rpx;
  280. }
  281. .container {
  282. display: flex;
  283. justify-content: space-between;
  284. align-items: center;
  285. }
  286. .left-text {
  287. font-weight: 600;
  288. font-size: 27rpx;
  289. color: #141414;
  290. margin-left: 40rpx;
  291. }
  292. .right-group {
  293. display: flex;
  294. align-items: center;
  295. gap: 16rpx;
  296. }
  297. .image {
  298. width: 42rpx;
  299. height: 70rpx;
  300. margin-right: 20rpx;
  301. }
  302. .container2 {
  303. display: flex;
  304. justify-content: space-between;
  305. align-items: center;
  306. background-color: #F8F9FB;
  307. margin: 20rpx 20rpx 0 20rpx;
  308. padding: 20rpx 40rpx 20rpx 20rpx;
  309. }
  310. .left-text2 {
  311. font-weight: 600;
  312. color: #141414;
  313. font-size: 23rpx;
  314. margin-left: 0;
  315. }
  316. .image2 {
  317. width: 42rpx;
  318. height: 42rpx;
  319. }
  320. .scroll-container {
  321. display: flex;
  322. overflow-x: auto;
  323. /* 允许水平滚动 */
  324. white-space: nowrap;
  325. /* 防止项目换行 */
  326. padding: 8rpx 20rpx 20rpx 40rpx;
  327. /* 添加一些内边距 */
  328. -webkit-overflow-scrolling: touch;
  329. /* 在iOS上平滑滚动 */
  330. }
  331. .item {
  332. display: inline-flex;
  333. /* 或者使用 flex 但需要调整 */
  334. flex-direction: column;
  335. align-items: center;
  336. margin-right: 20rpx;
  337. /* 项目之间的间距 */
  338. flex: 0 0 auto;
  339. /* 防止项目伸缩 */
  340. }
  341. .item img {
  342. width: 115rpx;
  343. height: 115rpx;
  344. border-radius: 12rpx;
  345. /* 可选:圆形图片 */
  346. object-fit: cover;
  347. /* 保持图片比例 */
  348. }
  349. .item text {
  350. margin-top: 10rpx;
  351. /* 图片和文字之间的间距 */
  352. font-size: 21rpx;
  353. color: #141414;
  354. text-align: center;
  355. white-space: nowrap;
  356. /* 防止文字换行 */
  357. }
  358. .dashed-line {
  359. border-bottom: 2rpx dashed #D6D7DC;
  360. width: 90%;
  361. /* 确保宽度足够 */
  362. height: 2rpx;
  363. /* 控制线条高度 */
  364. margin: 0 40rpx 18rpx 40rpx;
  365. }
  366. .nbox-1 {
  367. padding: 20rpx;
  368. box-sizing: border-box;
  369. display: flex;
  370. flex-direction: column;
  371. gap: 20rpx;
  372. }
  373. .nbox-2 {
  374. background: #FFF;
  375. padding: 15rpx;
  376. box-sizing: border-box;
  377. }
  378. .top-1 {
  379. background-color: #FF6702;
  380. position: sticky;
  381. top: 0;
  382. }
  383. </style>