index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. <template>
  2. <view class="flex-common-css iPhone-bottom box-border-box bgc-F5F4F9">
  3. <newNav textName="订单" navBackgroundColor='#fff' titleColor='#333' leftIconColor="#333"></newNav>
  4. <view v-if="list.length <= 0" class="scroll-view-css">
  5. <EnBlank :customSrc='true'>
  6. <template v-slot:blankImg>
  7. <image class="black-custom-img" src="@/static/img/common/no-order.png" mode=""></image>
  8. </template>
  9. </EnBlank>
  10. </view>
  11. <scroll-view v-else :scroll-y="true" class="scroll-view-css" @scrolltolower="scrolltolower">
  12. <view class="list-box p-20 box-border-box">
  13. <view class="list-item bgc-f b-rad-20 mb-20 p-24 box-border-box" v-for="(item,index) in list"
  14. @click="goToInfo(item)">
  15. <view class="align-items-center flex-justify-space mb-24">
  16. <view class="align-items-center">
  17. <image class="shops-img mr-4" src="@/static/img/order-food/shop-icon.png" mode=""></image>
  18. <view class="fs-30 fc-3 fw-600 shops-name text-overflow-ellipsis-one">
  19. {{item.shop_name}}
  20. </view>
  21. </view>
  22. <view class="fc-FF3333 fs-28">
  23. {{item.order_status_str}}
  24. </view>
  25. </view>
  26. <view class="align-items-center flex-justify-space mb-24">
  27. <view class="goods-box">
  28. <view class="" v-if="item.item.length == 1">
  29. <view class="align-items-center" v-for="(itemGoods,indexGoods) in item.item">
  30. <image class="goods-img flex-shrink0" :src="itemGoods.goods_img" mode="aspectFill">
  31. </image>
  32. <view class="fs-28 fc-6 text-overflow-ellipsis">
  33. {{itemGoods.goods_name}}
  34. </view>
  35. </view>
  36. </view>
  37. <view class="align-items-center goods-two" v-else>
  38. <view class="flex-direction" v-for="(itemGoods,indexGoods) in item.item">
  39. <image class="goods-img flex-shrink0" :src="itemGoods.goods_img" mode="aspectFill">
  40. </image>
  41. <view
  42. class="fs-28 fc-6 text-overflow-ellipsis-one goods-two-name text-align-center">
  43. {{itemGoods.goods_name}}
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. <view class="goods-num fc-6 fs-24 text-align-center">
  49. 共 {{item.goods_number}} 件
  50. </view>
  51. </view>
  52. <view class="align-items-center flex-justify-space mb-24">
  53. <view class="fs-24 fc-9">
  54. 下单时间:{{item.created_at}}
  55. </view>
  56. <view class="align-items-center">
  57. <view class="fs-28 fc-9">
  58. 实付
  59. </view>
  60. <view class="fs-32 fc-3 fw-600">
  61. ¥{{item.pay_money}}
  62. </view>
  63. </view>
  64. </view>
  65. <view class="align-items-center flex-justify-end">
  66. <view v-if="item.order_status === 1" @click.stop="orderPay(item)"
  67. class="item-but but-class-one fs-28">
  68. 立即支付
  69. </view>
  70. <view v-else @click.stop="goToUrl(item)" class="item-but but-class-one fs-28">
  71. 再来一单
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. </scroll-view>
  77. </view>
  78. </template>
  79. <script>
  80. // import UniQrcode from 'uniapp-qrcode'
  81. import tools from '@/service/tools';
  82. import cartStore from '@/utils/cartStore';
  83. import EnBlank from "@/components/en-utils/en-blank/en-blank";
  84. import {
  85. commonRefundReason
  86. } from "@/api/common.js"
  87. import {
  88. orderList,
  89. orderCancel,
  90. orderPay
  91. } from "@/api/order.js"
  92. import {
  93. expressOrderCancel
  94. } from "@/api/expressOrder.js"
  95. import {
  96. errandsOrderCancel
  97. } from "@/api/errandsOrder.js"
  98. import {
  99. laundryOrderCancel,
  100. laundryPay
  101. } from "@/api/laundryOrder.js"
  102. export default {
  103. components: {
  104. EnBlank
  105. },
  106. data() {
  107. return {
  108. type: 1,
  109. page: 1,
  110. list: [],
  111. total: 0,
  112. isAjax: false,
  113. refundReason: [],
  114. order_id: 0,
  115. orderData: {}
  116. };
  117. },
  118. onShow() {
  119. this.list = []
  120. this.page = 1
  121. this.orderList()
  122. },
  123. onLoad() {},
  124. onHide() {},
  125. onUnload() {},
  126. mounted() {},
  127. methods: {
  128. goToUrl(item) {
  129. // 再来一单
  130. tools.showLoading()
  131. this.orderData = item.shopping_cart
  132. const success = cartStore.reorderFromOrderData(
  133. uni.getStorageSync('shop_id'),
  134. this.orderData
  135. );
  136. if (success) {
  137. // 延迟跳转,让用户看到成功提示
  138. setTimeout(() => {
  139. // 跳转到店铺页面
  140. tools.hideLoading()
  141. uni.redirectTo({
  142. url: '/pages-takeout/new-shop'
  143. })
  144. }, 1500);
  145. } else {
  146. tools.error('再来一单失败');
  147. }
  148. },
  149. goToInfo(item) {
  150. uni.navigateTo({
  151. url: `/pages-order/takeout-info?orderId=` + item.id
  152. })
  153. },
  154. orderPay(item) {
  155. // 立即支付
  156. this.takeawayPay(item.id)
  157. },
  158. scrolltolower() {
  159. ++this.page
  160. this.orderList()
  161. // console.log('触底');
  162. },
  163. orderList() {
  164. tools.showLoading()
  165. // 订单列表
  166. orderList({
  167. page: this.page
  168. }).then((res) => {
  169. if (res.code == 1) {
  170. tools.hideLoading()
  171. this.total = res.data.total
  172. this.list = [...this.list, ...res.data.items]
  173. }
  174. })
  175. },
  176. takeawayPay(id) {
  177. // 外卖支付
  178. if (this.isAJAX) {
  179. return
  180. }
  181. this.isAJAX = true;
  182. orderPay({
  183. order_id: id
  184. }).then((ret) => {
  185. if (ret.code === 1) {
  186. uni.requestPayment({
  187. provider: "wxpay", //支付类型-固定值
  188. timeStamp: ret.data.wx_pay.timeStamp + "", // 时间戳(单位:秒)
  189. nonceStr: ret.data.wx_pay.nonceStr, // 随机字符串
  190. package: ret.data.wx_pay.package, // 固定值
  191. signType: ret.data.wx_pay.signType, //固定值
  192. paySign: ret.data.wx_pay.paySign, //签名
  193. success: (ren) => {
  194. tools.success("支付成功");
  195. this.isAJAX = false;
  196. this.page = 1;
  197. this.list = [];
  198. this.orderList()
  199. },
  200. fail: (err) => {
  201. this.isAJAX = false;
  202. tools.error("支付失败");
  203. },
  204. });
  205. } else {
  206. this.isAJAX = false;
  207. tools.error("支付失败");
  208. }
  209. })
  210. },
  211. },
  212. }
  213. </script>
  214. <style lang="scss" scoped>
  215. .pop-b {
  216. height: 80rpx;
  217. line-height: 80rpx;
  218. border-radius: 20rpx;
  219. // border: 1rpx solid #F9F9F9;
  220. }
  221. .popup-reason-box {
  222. width: 100%;
  223. height: 45vh;
  224. overflow: auto;
  225. border-radius: 20rpx 20rpx 0 0;
  226. background: #fff;
  227. padding: 24rpx 0 0;
  228. box-sizing: border-box;
  229. }
  230. .picker-view {
  231. width: 100%;
  232. // height: 70%;
  233. }
  234. .picker-view-item {
  235. // height: 90rpx;
  236. line-height: 68rpx;
  237. text-align: center;
  238. background: #F5F5F5;
  239. }
  240. .nav-b {
  241. position: relative;
  242. z-index: -1 !important;
  243. }
  244. .nav-box {
  245. padding: 26rpx 44rpx;
  246. overflow-x: scroll;
  247. .nav-item {
  248. white-space: nowrap;
  249. position: relative;
  250. .nav-item-x {
  251. position: absolute;
  252. width: 48rpx;
  253. height: 6rpx;
  254. border-radius: 20rpx;
  255. background-color: #41ABF5;
  256. left: calc(50% - 24rpx);
  257. bottom: -10rpx;
  258. }
  259. }
  260. }
  261. .nav-type-box {
  262. width: 100%;
  263. white-space: nowrap;
  264. }
  265. .nav-type-item {
  266. width: 144rpx;
  267. height: 64rpx;
  268. line-height: 64rpx;
  269. margin: 0 24rpx 0 0;
  270. border-radius: 200rpx;
  271. display: inline-block;
  272. }
  273. .nav-type-item:last-child {
  274. margin: 0;
  275. }
  276. .shops-img {
  277. width: 48rpx;
  278. height: 48rpx;
  279. }
  280. .shops-name {
  281. max-width: 422rpx;
  282. margin: 0 8rpx 0 0;
  283. }
  284. .icons {
  285. width: 32rpx;
  286. height: 32rpx;
  287. }
  288. .goods-box {
  289. max-width: 506rpx;
  290. height: auto;
  291. }
  292. .goods-num {
  293. width: 24rpx;
  294. height: auto;
  295. }
  296. .goods-img {
  297. width: 144rpx;
  298. height: 144rpx;
  299. border-radius: 12rpx;
  300. margin: 0 16rpx 0 0;
  301. }
  302. .goods-two {
  303. overflow-x: scroll;
  304. overflow: auto;
  305. }
  306. .goods-two-name {
  307. width: 144rpx;
  308. }
  309. .item-but {
  310. width: 160rpx;
  311. height: 64rpx;
  312. line-height: 64rpx;
  313. text-align: center;
  314. border-radius: 200rpx;
  315. }
  316. .but-class-one {
  317. background: linear-gradient(270deg, #FF3333 0%, #FE6122 100%);
  318. color: #fff;
  319. }
  320. .but-class-two {
  321. background: #fff;
  322. border: 2rpx solid #CCCCCC;
  323. color: #333;
  324. }
  325. </style>