index.vue 10 KB

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