detail.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <view>
  3. <view class="addr_item">
  4. <view class="contact_user" style="display: flex; justify-content: space-between; width: 100%">
  5. <view style="display: flex">
  6. <text class="contact_name">{{ order_datail.order_addr?.contact_name }}</text>
  7. <text class="contact_phone">{{ order_datail.order_addr?.contact_phone }}</text>
  8. </view>
  9. <view class="contact_shop text-ellipsis" style="width: 250rpx; text-align: end">
  10. <text v-if="order_datail.order_addr?.shop_type">({{ $CONSTANTS.SHOP_TYPES[order_datail.order_addr?.shop_type] }})&nbsp;</text>
  11. {{ order_datail.order_addr?.contact_shop }}
  12. </view>
  13. </view>
  14. <view class="contact_addr"
  15. >{{ order_datail.order_addr?.contact_province }} {{ order_datail.order_addr?.contact_city }} {{ order_datail.order_addr?.contact_area }} {{ order_datail.order_addr?.contact_addr }}</view
  16. >
  17. </view>
  18. <view class="car_list">
  19. <view class="business_name"> {{ order_datail?.business_name }}</view>
  20. <view class="car_item" v-for="(item, index) in order_datail.order_items" :key="index" @click="_navToProduct(item.product_id)">
  21. <view class="box_left">
  22. <image class="car_image" :src="item.product_thumb" mode=""></image>
  23. </view>
  24. <view class="box_center">
  25. <view class="car_name">{{ item.product_name }}</view>
  26. <view class="car_spec">{{ item.product_spec }}</view>
  27. <view v-if="item.promo_title" class="promo_title">{{ item.promo_title }}</view>
  28. <view class="car_price">
  29. <text class="price">¥{{ item.pay_total }}</text>
  30. </view>
  31. </view>
  32. <view class="box_right">
  33. <view class="buy_num_box">
  34. <view class="buy_num">共{{ item.buy_num }}件</view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="price_content">
  40. <view class="price_content_item">
  41. <view>订单编号</view>
  42. <view style="display: flex; align-items: center">
  43. <view>{{ order_datail?.order_code }}</view
  44. >&nbsp;
  45. <view v-if="order_datail?.order_code" class="copy_btn" @click="_copyorderCode(order_datail?.order_code)">复制</view>
  46. </view>
  47. </view>
  48. <view class="price_content_item">
  49. <view>下单时间</view>
  50. <view>{{ order_datail?.insert_time }}</view>
  51. </view>
  52. <view class="price_content_title"></view>
  53. <view class="price_content_item">
  54. <view>订单总价</view>
  55. <view>¥{{ order_datail?.price_total }}</view>
  56. </view>
  57. <view class="price_content_item">
  58. <view>优惠价格</view>
  59. <view>¥-{{ order_datail?.coupon_total }}</view>
  60. </view>
  61. <view class="price_content_item">
  62. <view>订单金额</view>
  63. <view class="price">¥{{ order_datail?.pay_total }}</view>
  64. </view>
  65. </view>
  66. </view>
  67. </template>
  68. <script>
  69. export default {
  70. data() {
  71. return {
  72. order_datail: {},
  73. };
  74. },
  75. onLoad(param) {
  76. this._getOrderDetail(param.order_id); // 获取并打印订单详情
  77. },
  78. methods: {
  79. _getOrderDetail(orderId) {
  80. this.$http
  81. .request("api/orders/get_detail", { id: orderId })
  82. .then((response) => {
  83. if (response.code == "success") {
  84. this.order_datail = response.data; // 打印订单详情
  85. }
  86. })
  87. .catch((error) => {
  88. uni.showToast({
  89. title: "获取订单详情失败",
  90. icon: "error",
  91. duration: 2000,
  92. });
  93. });
  94. },
  95. _navToProduct(id) {
  96. if (id) {
  97. uni.navigateTo({
  98. url: "/pages/product/index?product_id=" + id,
  99. });
  100. }
  101. },
  102. _copyorderCode(info) {
  103. // #ifndef H5
  104. //uni.setClipboardData方法就是讲内容复制到粘贴板
  105. uni.setClipboardData({
  106. data: info, //要被复制的内容
  107. success: () => {
  108. //复制成功的回调函数
  109. uni.showToast({
  110. //提示
  111. title: "复制成功",
  112. });
  113. },
  114. });
  115. // #endif
  116. // #ifdef H5
  117. let textarea = document.createElement("textarea");
  118. textarea.value = info;
  119. textarea.readOnly = "readOnly";
  120. document.body.appendChild(textarea);
  121. textarea.select(); // 选中文本内容
  122. textarea.setSelectionRange(0, info.length);
  123. uni.showToast({
  124. //提示
  125. title: "复制成功",
  126. });
  127. result = document.execCommand("copy");
  128. textarea.remove();
  129. // #endif
  130. },
  131. },
  132. };
  133. </script>
  134. <style lang="less" scoped>
  135. .addr_item {
  136. font-size: 24rpx;
  137. overflow: hidden;
  138. line-height: 40rpx;
  139. padding: 20rpx 35rpx;
  140. border-radius: 15rpx;
  141. padding-bottom: 0rpx;
  142. margin-bottom: 10rpx;
  143. background-color: #ffffff;
  144. .contact_user {
  145. font-size: 24rpx;
  146. line-height: 50rpx;
  147. .contact_name {
  148. font-size: 26rpx;
  149. font-weight: bold;
  150. margin-right: 16rpx;
  151. }
  152. .contact_shop {
  153. float: right;
  154. }
  155. }
  156. .contact_addr {
  157. font-size: 24rpx;
  158. line-height: 30rpx;
  159. padding: 10rpx 5rpx;
  160. }
  161. }
  162. .car_list {
  163. display: block;
  164. overflow: hidden;
  165. margin: 0rpx auto;
  166. margin-top: 20rpx;
  167. background: #ffffff;
  168. margin-bottom: 20rpx;
  169. .business_name {
  170. padding: 8rpx 35rpx;
  171. border-bottom: 1px solid #f3f3f3;
  172. font-size: 32rpx;
  173. z-index: 1;
  174. display: flex;
  175. align-items: center;
  176. .business_icon {
  177. width: 48rpx;
  178. height: 48rpx;
  179. margin-right: 10rpx;
  180. }
  181. }
  182. .car_item {
  183. height: 170rpx;
  184. display: block;
  185. overflow: hidden;
  186. margin: 0rpx auto;
  187. padding: 20rpx 35rpx;
  188. border-bottom: 2rpx solid #dddddd;
  189. .box_left {
  190. float: left;
  191. width: 140rpx;
  192. height: 190rpx;
  193. margin-top: 10rpx;
  194. .car_image {
  195. width: 140rpx;
  196. height: 140rpx;
  197. border-radius: 5rpx;
  198. }
  199. }
  200. .box_center {
  201. float: left;
  202. width: 300rpx;
  203. margin-left: 25rpx;
  204. .car_name {
  205. max-height: 70rpx;
  206. font-size: 30rpx;
  207. line-height: 40rpx;
  208. overflow: hidden;
  209. white-space: nowrap;
  210. /* 不换行 */
  211. overflow: hidden;
  212. /* 隐藏超出的内容 */
  213. text-overflow: ellipsis;
  214. /* 用省略号表示被隐藏的部分 */
  215. }
  216. .car_spec {
  217. color: #999999;
  218. font-size: 24rpx;
  219. line-height: 60rpx;
  220. max-height: 60rpx;
  221. overflow: hidden;
  222. }
  223. .promo_title {
  224. max-height: 80rpx;
  225. font-size: 20rpx;
  226. line-height: 40rpx;
  227. overflow: hidden;
  228. padding: 0rpx 0rpx;
  229. color: #dd524d;
  230. }
  231. .car_price {
  232. font-size: 30rpx;
  233. line-height: 60rpx;
  234. .price {
  235. color: red;
  236. }
  237. }
  238. }
  239. .box_right {
  240. float: right;
  241. width: 185rpx;
  242. .buy_num_box {
  243. float: right;
  244. color: #333333;
  245. overflow: hidden;
  246. font-size: 24rpx;
  247. margin-top: 130rpx;
  248. text-align: center;
  249. .buy_num {
  250. float: left;
  251. width: 100rpx;
  252. height: 30rpx;
  253. font-size: 24rpx;
  254. line-height: 30rpx;
  255. padding: 0rpx 0rpx;
  256. border-radius: 8rpx;
  257. }
  258. }
  259. }
  260. }
  261. .car_item:last-child {
  262. border-bottom: none;
  263. }
  264. }
  265. .price_content {
  266. background-color: #fff;
  267. bottom: var(--window-bottom);
  268. padding: 40rpx 35rpx 20rpx;
  269. width: 100%;
  270. box-sizing: border-box;
  271. .price_content_title {
  272. margin-bottom: 20rpx;
  273. border-bottom: 1px dashed #f3f3f3;
  274. }
  275. .price_content_item {
  276. margin-bottom: 20rpx;
  277. display: flex;
  278. justify-content: space-between;
  279. align-items: center;
  280. font-size: 24rpx;
  281. color: #00000073;
  282. .price {
  283. color: red;
  284. }
  285. }
  286. .copy_btn {
  287. border-radius: 20rpx;
  288. background-color: #f3f3f3;
  289. font-size: 24rpx;
  290. width: 100rpx;
  291. height: 45rpx;
  292. display: flex;
  293. align-items: center;
  294. justify-content: center;
  295. }
  296. }
  297. </style>