index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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-32 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-41ABF5 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. onLoad() {
  120. this.orderList()
  121. },
  122. onHide() {},
  123. onUnload() {},
  124. mounted() {},
  125. methods: {
  126. goToUrl(item) {
  127. // 再来一单
  128. tools.showLoading()
  129. this.orderData = item.shopping_cart
  130. const success = cartStore.reorderFromOrderData(
  131. uni.getStorageSync('shop_id'),
  132. this.orderData
  133. );
  134. if (success) {
  135. // 延迟跳转,让用户看到成功提示
  136. setTimeout(() => {
  137. // 跳转到店铺页面
  138. tools.hideLoading()
  139. uni.redirectTo({
  140. url: '/pages-takeout/new-shop'
  141. })
  142. }, 1500);
  143. } else {
  144. tools.error('再来一单失败');
  145. }
  146. },
  147. goToInfo(item) {
  148. uni.navigateTo({
  149. url: `/pages-order/takeout-info?orderId=` + item.id
  150. })
  151. },
  152. orderPay(item) {
  153. // 立即支付
  154. this.takeawayPay(item.id)
  155. },
  156. scrolltolower() {
  157. ++this.page
  158. this.orderList()
  159. // console.log('触底');
  160. },
  161. orderList() {
  162. // 订单列表
  163. orderList({
  164. page: this.page
  165. }).then((res) => {
  166. if (res.code == 1) {
  167. this.total = res.data.total
  168. this.list = [...this.list, ...res.data.items]
  169. }
  170. })
  171. },
  172. takeawayPay(id) {
  173. // 外卖支付
  174. if (this.isAJAX) {
  175. return
  176. }
  177. this.isAJAX = true;
  178. orderPay({
  179. order_id: id
  180. }).then((ret) => {
  181. if (ret.code === 1) {
  182. uni.requestPayment({
  183. provider: "wxpay", //支付类型-固定值
  184. timeStamp: ret.data.wx_pay.timeStamp + "", // 时间戳(单位:秒)
  185. nonceStr: ret.data.wx_pay.nonceStr, // 随机字符串
  186. package: ret.data.wx_pay.package, // 固定值
  187. signType: ret.data.wx_pay.signType, //固定值
  188. paySign: ret.data.wx_pay.paySign, //签名
  189. success: (ren) => {
  190. tools.success("支付成功");
  191. this.isAJAX = false;
  192. this.page = 1;
  193. this.list = [];
  194. this.orderList()
  195. },
  196. fail: (err) => {
  197. this.isAJAX = false;
  198. tools.error("支付失败");
  199. },
  200. });
  201. } else {
  202. this.isAJAX = false;
  203. tools.error("支付失败");
  204. }
  205. })
  206. },
  207. },
  208. }
  209. </script>
  210. <style lang="scss" scoped>
  211. .pop-b {
  212. height: 80rpx;
  213. line-height: 80rpx;
  214. border-radius: 20rpx;
  215. // border: 1rpx solid #F9F9F9;
  216. }
  217. .popup-reason-box {
  218. width: 100%;
  219. height: 45vh;
  220. overflow: auto;
  221. border-radius: 20rpx 20rpx 0 0;
  222. background: #fff;
  223. padding: 24rpx 0 0;
  224. box-sizing: border-box;
  225. }
  226. .picker-view {
  227. width: 100%;
  228. // height: 70%;
  229. }
  230. .picker-view-item {
  231. // height: 90rpx;
  232. line-height: 68rpx;
  233. text-align: center;
  234. background: #F5F5F5;
  235. }
  236. .nav-b {
  237. position: relative;
  238. z-index: -1 !important;
  239. }
  240. .nav-box {
  241. padding: 26rpx 44rpx;
  242. overflow-x: scroll;
  243. .nav-item {
  244. white-space: nowrap;
  245. position: relative;
  246. .nav-item-x {
  247. position: absolute;
  248. width: 48rpx;
  249. height: 6rpx;
  250. border-radius: 20rpx;
  251. background-color: #41ABF5;
  252. left: calc(50% - 24rpx);
  253. bottom: -10rpx;
  254. }
  255. }
  256. }
  257. .nav-type-box {
  258. width: 100%;
  259. white-space: nowrap;
  260. }
  261. .nav-type-item {
  262. width: 144rpx;
  263. height: 64rpx;
  264. line-height: 64rpx;
  265. margin: 0 24rpx 0 0;
  266. border-radius: 200rpx;
  267. display: inline-block;
  268. }
  269. .nav-type-item:last-child {
  270. margin: 0;
  271. }
  272. .shops-img {
  273. width: 48rpx;
  274. height: 48rpx;
  275. }
  276. .shops-name {
  277. max-width: 422rpx;
  278. margin: 0 8rpx 0 0;
  279. }
  280. .icons {
  281. width: 32rpx;
  282. height: 32rpx;
  283. }
  284. .goods-box {
  285. max-width: 506rpx;
  286. height: auto;
  287. }
  288. .goods-num {
  289. width: 24rpx;
  290. height: auto;
  291. }
  292. .goods-img {
  293. width: 144rpx;
  294. height: 144rpx;
  295. border-radius: 12rpx;
  296. margin: 0 16rpx 0 0;
  297. }
  298. .goods-two {
  299. overflow-x: scroll;
  300. overflow: auto;
  301. }
  302. .goods-two-name {
  303. width: 144rpx;
  304. }
  305. .item-but {
  306. width: 160rpx;
  307. height: 64rpx;
  308. line-height: 64rpx;
  309. text-align: center;
  310. border-radius: 200rpx;
  311. }
  312. .but-class-one {
  313. background: linear-gradient(270deg, #FF3333 0%, #FE6122 100%);
  314. color: #fff;
  315. }
  316. .but-class-two {
  317. background: #fff;
  318. border: 2rpx solid #CCCCCC;
  319. color: #333;
  320. }
  321. </style>