orderDetail.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. <template>
  2. <view class="content">
  3. <view class="row b-b b-t">
  4. <text class="order-status">{{ item._status ? item._status._msg : '' }}</text>
  5. </view>
  6. <view class="address-box position-relative">
  7. <view class="address-top flex">
  8. <view class="title" v-if="type == 0">{{ item.real_name}}</view>
  9. <view class="title" v-if="type == 1">{{ real_name }}</view>
  10. <view class="phone" v-if="type == 0">{{ item.user_phone }}</view>
  11. <view class="phone" v-if="type == 1">{{ user_phone}}</view>
  12. </view>
  13. <view class="addrdss-detail" v-if="type == 1">{{ user_address }}</view>
  14. <view class="addrdss-detail" v-if="type == 0">{{ item.user_address }}</view>
  15. <image class="a-bg" :src="addressImg"></image>
  16. </view>
  17. <view class="order-item">
  18. <view class="order-title flex" v-if="type == 1">
  19. <view class="name">商品信息</view>
  20. <view class="ToHome" @click="ToHome">去首页</view>
  21. </view>
  22. <view class="goods-box-single" v-for="(goodsItem, goodsIndex) in item.cartInfo" :key="goodsIndex">
  23. <image class="goods-img" :src="goodsItem.productInfo.image" mode="aspectFill"></image>
  24. <view class="right position-relative">
  25. <text class="title">{{ goodsItem.productInfo.store_name }}</text>
  26. </view>
  27. <view class="title-right">
  28. <view class="price">{{ goodsItem.productInfo.price }}</view>
  29. <view class="attr-box">{{ goodsItem.attrInfo ? goodsItem.attrInfo.suk : '' }} x {{ goodsItem.cart_num }}</view>
  30. <view v-if="type == 0">
  31. <view v-if="status._type == 3">
  32. <view @click="evaluate(goodsItem)" class="yesevaluate" v-if="goodsItem.is_reply > 0"><text>已评价</text></view>
  33. <view @click="evaluate(goodsItem)" class="evaluate" v-if="goodsItem.is_reply < 1"><text>去评价</text></view>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. <view class="goods-box-single" v-if="gift_info != ''">
  39. <image class="goods-img" :src="gift_info.image" mode="aspectFill"></image>
  40. <view class="right position-relative">
  41. <text class="title">{{ gift_info.store_name }}</text>
  42. </view>
  43. <view class="title-right">
  44. <view class="evaluate"><text>赠品</text></view>
  45. </view>
  46. </view>
  47. <view class="goods-box-single" v-if="activityProductInfo != ''">
  48. <image class="goods-img" :src="activityProductInfo.image" mode="aspectFill"></image>
  49. <view class="right position-relative">
  50. <text class="title">{{ activityProductInfo.store_name }}</text>
  51. </view>
  52. <view class="title-right">
  53. <view class="evaluate"><text>活动赠品</text></view>
  54. </view>
  55. </view>
  56. <view class="goods-box-single" v-if="productCouponInfo != ''">
  57. <image class="goods-img" :src="productCouponInfo.image" mode="aspectFill"></image>
  58. <view class="right position-relative">
  59. <text class="title">{{ productCouponInfo.store_name }}</text>
  60. </view>
  61. <view class="title-right">
  62. <view class="evaluate"><text>商品券</text></view>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="row b-b flex">
  67. <text class="tit">订单总价</text>
  68. <view class="input">¥{{ item.total_price }}</view>
  69. </view>
  70. <view class="row b-b flex">
  71. <text class="tit">邮费</text>
  72. <view class="input">{{ item.pay_postage > 0 ? '¥' + item.pay_postage : '免邮费' }}</view>
  73. </view>
  74. <view class="row b-b flex" v-if="item.isBuyVip == 1">
  75. <text class="tit">开通会员</text>
  76. <view class="input">{{item.vipBuyPrice}}</view>
  77. </view>
  78. <view class="row b-b flex" v-if="item.coupon_id > 0">
  79. <text class="tit">优惠券</text>
  80. <view class="input">-¥{{ item.coupon_price }}</view>
  81. </view>
  82. <view class="row b-b flex" v-if="item.use_integral > 0">
  83. <text class="tit">积分抵扣</text>
  84. <view class="input">-¥{{ item.use_integral }}</view>
  85. </view>
  86. <view class="row b-b flex">
  87. <text class="tit ">实付</text>
  88. <view class="input payColor">¥{{ item.pay_price }}</view>
  89. </view>
  90. <view class="orderDetialBox">
  91. <view class="f-header m-t">
  92. <view class="f-left-icon"></view>
  93. <view class="tit-box"><text class="tit">订单信息</text></view>
  94. </view>
  95. <view class="item flex">
  96. <view class="title-left flex">
  97. <text class="title">订单编号:</text>
  98. <view class="text">{{ item.order_id }}</view>
  99. </view>
  100. <view class="buttom-right" @click="copyOrderId(item.order_id)">复制单号</view>
  101. </view>
  102. <view class="item flex">
  103. <view class="title-left flex">
  104. <text class="title">送达时间:</text>
  105. <view class="text">{{ item.estimated_time }}</view>
  106. </view>
  107. </view>
  108. <view class="item flex">
  109. <view class="title-left flex">
  110. <text class="title">下单时间:</text>
  111. <view class="text">{{ item._add_time }}</view>
  112. </view>
  113. </view>
  114. <view class="item flex">
  115. <view class="title-left flex">
  116. <text class="title">订单类型:</text>
  117. <view class="text">{{ item | orderType }}</view>
  118. </view>
  119. </view>
  120. <view class="item flex">
  121. <view class="title-left flex">
  122. <text class="title">订单状态:</text>
  123. <view class="text">{{ status._title }}</view>
  124. </view>
  125. </view>
  126. <view class="item flex">
  127. <view class="title-left flex">
  128. <text class="title">支付方式:</text>
  129. <view class="text">{{ status._payType }}</view>
  130. </view>
  131. </view>
  132. </view>
  133. <view class="orderDetialBox" v-if="item.delivery_id">
  134. <view class="item flex">
  135. <view class="title-left flex">
  136. <text class="title">配送方式:</text>
  137. <view class="text">{{ item.delivery_type=='express'?'发货':item.delivery_type=='send'?'送货':'' }}</view>
  138. </view>
  139. </view>
  140. <view class="item flex">
  141. <view class="title-left flex">
  142. <text class="title" v-if="item.delivery_type=='express'">快递公司:</text>
  143. <text class="title" v-if="item.delivery_type=='send'">送货人员:</text>
  144. <view class="text">{{ item.delivery_name }}</view>
  145. </view>
  146. </view>
  147. <view class="item flex">
  148. <view class="title-left flex">
  149. <text class="title" v-if="item.delivery_type=='express'">快递单号:</text>
  150. <text class="title" v-if="item.delivery_type=='send'">联系方式:</text>
  151. <view class="text">{{ item.delivery_id }}</view>
  152. </view>
  153. </view>
  154. </view>
  155. <view v-if="type==0">
  156. <button open-type="share" class="shareDate"><image src="/static/img/share.png"></image></button>
  157. </view>
  158. </view>
  159. </template>
  160. <script>
  161. import { orderDetail } from '@/api/order.js';
  162. import { saveUrl } from '@/utils/loginUtils.js';
  163. export default {
  164. filters: {
  165. orderType: function(item) {
  166. if (item.combination_id > 0) {
  167. return '拼团订单';
  168. } else if (item.seckill_id > 0) {
  169. return '秒杀订单';
  170. } else if (item.bargain_id > 0) {
  171. return '砍价订单';
  172. } else if (item.jl_id > 0) {
  173. return '接龙订单';
  174. } else {
  175. return '普通订单';
  176. }
  177. }
  178. },
  179. data() {
  180. return {
  181. refund: '', //退款理由
  182. reason: '', //备注
  183. value: ['1', '2', '3', '4', '5', '6', '7', '8', 9, 10, 11, 12, 13],
  184. orderId: '',
  185. item: {},
  186. status:'',
  187. gift_info:'',
  188. addressImg:'/static/img/img35.png',
  189. real_name:'',
  190. user_phone:'',
  191. user_address:'',
  192. type:0,//判断是否是分享订单
  193. activityProductInfo:'',
  194. productCouponInfo:''
  195. };
  196. },
  197. onLoad(option) {
  198. this.orderId = option.id;
  199. // 判断有无邀请人
  200. if (option.spread) {
  201. uni.setStorageSync('spread', option.spread);
  202. }
  203. // 判断是否是分享订单
  204. if (option.type) {
  205. this.type = option.type;
  206. console.log(this.type,"type")
  207. }
  208. saveUrl();
  209. this.loadOrder();
  210. },
  211. methods: {
  212. // 载入订单详细
  213. loadOrder() {
  214. orderDetail({}, this.orderId).then(e => {
  215. this.item = e.data;
  216. if(e.data.gift_info){
  217. this.gift_info = JSON.parse(e.data.gift_info);
  218. }
  219. if(e.data.productCouponInfo){
  220. this.productCouponInfo = JSON.parse(e.data.productCouponInfo);
  221. }
  222. if(e.data.activityProductInfo){
  223. this.activityProductInfo = JSON.parse(e.data.activityProductInfo);
  224. }
  225. this.real_name = this.item.real_name;
  226. this.user_phone= this.item.user_phone.replace(/(\d{3})(\d{4})(\d{4})/,"$1****$3");
  227. this.real_name = this.formatName(this.item.real_name);
  228. this.user_address = this.formataddress(this.item.user_address);
  229. this.status = e.data._status;
  230. });
  231. },
  232. myTrim(x) {
  233. return x.replace(/^\s+|\s+$/gm,'');
  234. },
  235. formatName(name){
  236. let newStr = '';
  237. if (name.length === 2) {
  238. newStr = name.substr(0, 1) + '*';
  239. } else if (name.length > 2) {
  240. var char = '';
  241. for (let i = 0, len = name.length - 2; i < len; i++) {
  242. char += '*';
  243. }
  244. newStr = name.substr(0, 1) + char + name.substr(-1, 1);
  245. } else {
  246. newStr = name;
  247. }
  248. return newStr;
  249. },
  250. formataddress(address){
  251. let newStr = '';
  252. if (address.length === 2) {
  253. newStr = address.substr(0, 1) + '*';
  254. } else if (address.length > 2) {
  255. var char = '';
  256. for (let i = 0, len = address.length - 2; i < len; i++) {
  257. char += '*';
  258. }
  259. newStr = address.substr(0, 10) + char + address.substr(-1, 0);
  260. } else {
  261. newStr = address;
  262. }
  263. return newStr;
  264. },
  265. //分享
  266. // #ifdef MP
  267. onShareAppMessage(option){
  268. let GetInfo = uni.getStorageSync('GetInfo');
  269. let userInfo = uni.getStorageSync('userInfo');
  270. // 来自页面内分享按钮
  271. let pages = getCurrentPages();
  272. // 获取当前页面
  273. let page = pages[pages.length - 1];
  274. let path = page.route+'?id='+this.orderId +'&type=1';
  275. // 保存邀请人
  276. let shareObj = {
  277. path: path,
  278. imageUrl: 'http://shicai.liuniu946.com/static/img/share-img.jpg',
  279. title: '我是'+userInfo.nickname+',刚在美天选菜里下单了!',
  280. success: function(res) {
  281. // 转发成功之后的回调
  282. if (res.errMsg == 'shareAppMessage:ok') {
  283. }
  284. },
  285. fail: function() {
  286. // 转发失败之后的回调
  287. if (res.errMsg == 'shareAppMessage:fail cancel') {
  288. // 用户取消转发
  289. } else if (res.errMsg == 'shareAppMessage:fail') {
  290. // 转发失败,其中 detail message 为详细失败信息
  291. }
  292. }
  293. };
  294. console.log(shareObj)
  295. return shareObj;
  296. },
  297. // #endif
  298. //跳转到评价页面
  299. evaluate(e){
  300. let unique = e.unique;
  301. let is_reply = e.is_reply;
  302. if(is_reply == 0){
  303. uni.navigateTo({
  304. url: '/pages/order/evaluate?unique=' + unique
  305. });
  306. }else{
  307. uni.showToast({
  308. title: '已评价!',
  309. duration: 1500,
  310. icon:"none"
  311. });
  312. }
  313. },
  314. ToHome(){
  315. uni.switchTab({
  316. url:"/pages/index/index"
  317. })
  318. },
  319. // 复制订单编号
  320. copyOrderId(text) {
  321. // #ifndef H5
  322. uni.setClipboardData({
  323. data: text,
  324. success: e => {
  325. uni.showToast({
  326. title: '复制成功',
  327. duration: 1500
  328. });
  329. }
  330. });
  331. // #endif
  332. // #ifdef H5
  333. let inputH = document.querySelector('#copyOrder input');
  334. // 获取需要复制的文字
  335. const copyStr = text;
  336. // 创建input标签存放需要复制的文字
  337. const oInput = document.createElement('input');
  338. // 把文字放进input中,供复制
  339. oInput.value = copyStr;
  340. // 添加文
  341. document.body.appendChild(oInput);
  342. // 选中创建的input
  343. oInput.select();
  344. // 执行复制方法, 该方法返回bool类型的结果,告诉我们是否复制成功
  345. const copyResult = document.execCommand('copy');
  346. // 操作中完成后 从Dom中删除创建的input
  347. document.body.removeChild(oInput);
  348. // 根据返回的复制结果 给用户不同的提示
  349. if (copyResult) {
  350. uni.showToast({
  351. title: '已复制到粘贴板',
  352. duration: 2000,
  353. icon:'none'
  354. });
  355. } else {
  356. this.$api.msg('复制失败');
  357. }
  358. // #endif
  359. }
  360. }
  361. };
  362. </script>
  363. <style lang="scss">
  364. page {
  365. background: #ffffff;
  366. height: 100%;
  367. }
  368. button::after{ border: none;}
  369. .shareDate{
  370. position: fixed;
  371. bottom: 7%;
  372. right: 10rpx;
  373. line-height:150rpx;
  374. height: 150rpx;
  375. background-color: #ffffff;
  376. image{
  377. width: 150rpx;
  378. height: 150rpx;
  379. }
  380. }
  381. // 订单详细
  382. .orderDetialBox {
  383. margin-top: 20rpx;
  384. padding: 0 30rpx;
  385. background-color: #ffffff;
  386. font-size: $font-base;
  387. color: $font-color-base;
  388. .item {
  389. height: 80rpx;
  390. .text {
  391. padding-left: 10rpx;
  392. }
  393. .buttom-right {
  394. width: 180rpx;
  395. border-radius: 99rpx;
  396. padding: 10rpx;
  397. text-align: center;
  398. border: 1px solid $border-color-light;
  399. }
  400. }
  401. }
  402. // 地址信息
  403. .address-box {
  404. margin-top: 20rpx;
  405. padding: 30rpx;
  406. padding-bottom: 35rpx;
  407. background-color: #ffffff;
  408. line-height: 1;
  409. .address-top {
  410. margin-bottom: 30rpx;
  411. .title {
  412. font-size: $font-lg;
  413. color: $font-color-dark;
  414. }
  415. .phone {
  416. font-size: $font-base;
  417. color: $font-color-light;
  418. }
  419. }
  420. .addrdss-detail {
  421. font-size: $font-base;
  422. color: $font-color-base;
  423. }
  424. .a-bg {
  425. position: absolute;
  426. bottom: 0;
  427. left: 0;
  428. width: 100%;
  429. height: 5rpx;
  430. }
  431. }
  432. .row {
  433. display: flex;
  434. align-items: center;
  435. position: relative;
  436. padding: 0 30rpx;
  437. height: 80rpx;
  438. background: #fff;
  439. .order-status {
  440. font-size: $font-lg;
  441. color: $color-red;
  442. font-weight: 500;
  443. }
  444. .refund {
  445. font-size: 30rpx;
  446. color: $font-color-dark;
  447. }
  448. .noRefund {
  449. font-size: 30rpx;
  450. color: $font-color-light;
  451. }
  452. .tit {
  453. flex-shrink: 0;
  454. width: 120rpx;
  455. font-size: 30rpx;
  456. color: $font-color-dark;
  457. }
  458. .input {
  459. text-align: right;
  460. flex: 1;
  461. font-size: 30rpx;
  462. color: $font-color-dark;
  463. &.payColor {
  464. color: $color-red;
  465. }
  466. }
  467. .iconlocation {
  468. font-size: 36rpx;
  469. color: $font-color-light;
  470. }
  471. }
  472. .add-btn {
  473. display: flex;
  474. align-items: center;
  475. justify-content: center;
  476. width: 690rpx;
  477. height: 80rpx;
  478. margin: 60rpx auto;
  479. font-size: $font-lg;
  480. color: #fff;
  481. background-color: $base-color;
  482. border-radius: 10rpx;
  483. // box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
  484. }
  485. /* 多条商品 */
  486. .order-item {
  487. display: flex;
  488. flex-direction: column;
  489. padding:0rpx 30rpx;
  490. background: #fff;
  491. margin-top: 20rpx;
  492. .order-title{
  493. font-size: 26rpx;
  494. padding: 25rpx 0rpx;
  495. border-bottom: 2rpx solid #f0f0f0;
  496. .name{
  497. font-size: 32rpx;
  498. }
  499. .ToHome{
  500. background-color: #FA2740;
  501. color: #FFFFFF;
  502. padding: 12rpx 25rpx;
  503. border-radius: 12rpx;
  504. }
  505. }
  506. /* 单条商品 */
  507. .goods-box-single {
  508. display: flex;
  509. padding: 20rpx 0;
  510. .goods-img {
  511. display: block;
  512. width: 120rpx;
  513. height: 120rpx;
  514. }
  515. .title-right {
  516. flex-shrink: 0;
  517. text-align: right;
  518. align-self: flex-start;
  519. .attr-box {
  520. font-size: $font-sm + 2rpx;
  521. color: $font-color-light;
  522. }
  523. .price {
  524. font-size: $font-base + 2rpx;
  525. color: $font-color-dark;
  526. &:before {
  527. content: '¥';
  528. font-size: $font-sm;
  529. margin: 0 2rpx 0 8rpx;
  530. }
  531. }
  532. .evaluate{
  533. color:#FFFFFF;
  534. font-size: 24rpx;
  535. display: inline-block;
  536. text-align: right;
  537. text{
  538. background:#FA2740;
  539. padding: 5rpx 15rpx;
  540. }
  541. }
  542. .yesevaluate{
  543. color:#333333;
  544. font-size: 24rpx;
  545. display: inline-block;
  546. text-align: right;
  547. text{
  548. border: 2rpx solid #333333;
  549. padding: 5rpx 15rpx;
  550. }
  551. }
  552. }
  553. .right {
  554. flex: 1;
  555. display: flex;
  556. flex-direction: column;
  557. padding:0rpx 15rpx;
  558. overflow: hidden;
  559. height: 100%;
  560. .title {
  561. font-size: 26rpx;
  562. color: $font-color-dark;
  563. width: 100%;
  564. height: 70rpx;
  565. overflow:hidden;
  566. text-overflow:ellipsis;
  567. display:-webkit-box;
  568. -webkit-box-orient:vertical;
  569. -webkit-line-clamp:2;
  570. }
  571. }
  572. }
  573. }
  574. // 标题头
  575. .f-header {
  576. display: flex;
  577. align-items: center;
  578. height: 80rpx;
  579. .tit-box {
  580. @extend %font-title-box;
  581. }
  582. .tit {
  583. @extend %font-title;
  584. }
  585. .f-left-icon {
  586. @extend %f-left-icon;
  587. }
  588. }
  589. </style>