order_detail.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. <template>
  2. <view class="wrap">
  3. <u-navbar title="订单详情" :placeholder="true" bgColor="rgba(255,255,255,0.3)" leftText="返回" :autoBack="true" titleStyle="font-weight:bold;color:#7a5831"></u-navbar>
  4. <view class="main" v-if="hasLoad">
  5. <view class="state-box" :class="stateStyle">
  6. <view class="iconfont" :class="stateIcon"></view>
  7. <view class="s-tit">{{ state.status_text }}</view>
  8. </view>
  9. <view class="gift-view" @click="onJumpGift(state.gift_data.id)">
  10. <view class="b-left">
  11. <image :src="state.gift_data.cover_url" mode="aspectFill"></image>
  12. </view>
  13. <view class="b-main">
  14. <view class="b-title">{{ state.gift_data.name }}</view>
  15. <view class="b-spec" v-if="state.gift_data.spec_data">
  16. <view class="s-tit">规格:</view>
  17. <view class="s-value">{{ state.gift_data.spec_data.name }}</view>
  18. </view>
  19. <view class="b-fund">
  20. <view class="s-worth" v-if="state.gift_data.order_worth > 0">价值 {{ state.gift_data.order_worth }}元</view>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="box" v-if="state.gift_data.type == 1">
  25. <view class="b-row">
  26. <view class="b-tit">领取方式</view>
  27. <view class="b-cont">
  28. <view class="s-cont s-text">{{ state.gain_method == 1 ? '线下领取' : '快递邮寄' }}</view>
  29. </view>
  30. </view>
  31. <view class="b-row" v-if="state.gain_method == 1 && state.gift_data.offline_place">
  32. <view class="b-tit">领取地点</view>
  33. <view class="b-cont">
  34. <view class="s-cont s-text">{{ state.gift_data.offline_place }}</view>
  35. </view>
  36. </view>
  37. <template v-if="state.address_data">
  38. <view class="b-row">
  39. <view class="b-tit">收货人</view>
  40. <view class="b-cont">
  41. <text class="s-name s-text">{{ state.address_data.name }}</text>
  42. <text class="s-phone s-text">{{ state.address_data.phone }}</text>
  43. </view>
  44. </view>
  45. <view class="b-row">
  46. <view class="b-tit">收件地址</view>
  47. <view class="b-cont">
  48. <view class="s-text">
  49. <text class="s-province">{{ state.address_data.province }}</text>
  50. <text class="s-city">{{ state.address_data.city }}</text>
  51. <text class="s-area">{{ state.address_data.area }}</text>
  52. <text class="s-address">{{ state.address_data.address }}</text>
  53. </view>
  54. </view>
  55. </view>
  56. </template>
  57. <view class="b-row">
  58. <view class="b-tit">留言</view>
  59. <view class="b-cont">
  60. <text class="s-text">{{ state.note }}</text>
  61. </view>
  62. </view>
  63. <template v-if="state.express_data">
  64. <view class="b-row">
  65. <view class="b-tit">快递公司</view>
  66. <view class="b-cont">
  67. <text class="s-text">{{ state.express_data.company }}</text>
  68. </view>
  69. </view>
  70. <view class="b-row">
  71. <view class="b-tit">快递单号</view>
  72. <view class="b-cont">
  73. <text class="s-text">{{ state.express_data.number }}</text>
  74. <text class="s-copy" @click="onCopy(state.express_data.number)">点击复制</text>
  75. </view>
  76. </view>
  77. </template>
  78. <view class="b-row" v-if="state.status == 2">
  79. <view class="b-tit">发货时间</view>
  80. <view class="b-cont">
  81. <text class="s-text">{{ timeFormat(state.deployed_at) }}</text>
  82. </view>
  83. </view>
  84. </view>
  85. <view class="box" v-if="state.gift_data.type == 2">
  86. <view class="b-row">
  87. <view class="b-tit">券码信息</view>
  88. <view class="b-cont">
  89. <text class="s-text">{{ state.gift_data.code_data.data }}</text>
  90. <text class="s-copy" @click="onCopy(state.gift_data.code_data.data)">点击复制</text>
  91. </view>
  92. </view>
  93. <view class="b-row f-link" v-if="state.gift_data.external_link">
  94. <view class="b-tit">兑换入口</view>
  95. <view class="b-cont">
  96. <view class="s-btn" @click="onExternalLink">点击进入</view>
  97. </view>
  98. </view>
  99. <view class="b-row" v-if="state.status == 2">
  100. <view class="b-tit">发货时间</view>
  101. <view class="b-cont">
  102. <text class="s-text">{{ timeFormat(state.deployed_at) }}</text>
  103. </view>
  104. </view>
  105. </view>
  106. <view class="box">
  107. <view class="b-row">
  108. <view class="b-tit">订单编号</view>
  109. <view class="b-cont">
  110. <text class="s-text">{{ state.number }}</text>
  111. <text class="s-copy" @click="onCopy(state.id)">点击复制</text>
  112. </view>
  113. </view>
  114. <view class="b-row">
  115. <view class="b-tit">兑换时间</view>
  116. <view class="b-cont">
  117. <text class="s-text">{{ timeFormat(state.created_at) }}</text>
  118. </view>
  119. </view>
  120. </view>
  121. <view class="action" v-if="submitIn">
  122. <view class="b-home" @click="onHome">返回首页</view>
  123. <view class="b-order" @click="onOrderList">我的订单</view>
  124. </view>
  125. <view class="navbar" v-if="!submitIn && state.gift_data.type == 1 && (state.status == 1 || state.express_data)">
  126. <view class="b-action">
  127. <view class="b-btn f-cancel" @click="onCancel" v-if="state.status == 1">取消订单</view>
  128. <view class="b-btn f-feed" @click="onExpressFeed" v-if="state.express_data">物流动态</view>
  129. </view>
  130. </view>
  131. </view>
  132. <!-- 加载中 -->
  133. <load-more :loadingType="loadingType" :loadingText="loadingText" :top="300"></load-more>
  134. </view>
  135. </template>
  136. <script>
  137. import { getOrderDetail, orderCancel } from '@/service/api/gift.js';
  138. import mixinsCommon from '@/mixins/common.js';
  139. import mixinsAuth from '../../mixins/auth.js';
  140. export default {
  141. mixins: [mixinsCommon, mixinsAuth],
  142. data() {
  143. return {
  144. recordId: 0,
  145. state: null,
  146. hasLoad: false,
  147. submitIn: false,
  148. loadingType: 1,
  149. loadingText: ''
  150. };
  151. },
  152. onLoad(options) {
  153. this.loadDetail(options.id);
  154. this.recordId = options.id;
  155. if (options.submit) {
  156. this.submitIn = true;
  157. }
  158. },
  159. computed: {
  160. stateStyle() {
  161. return {
  162. 'f-wait': this.state.status === 1,
  163. 'f-done': this.state.status === 2,
  164. 'f-cancel': this.state.status === 3
  165. };
  166. },
  167. stateIcon() {
  168. return {
  169. 'icon-wait': this.state.status === 1,
  170. 'icon-done': this.state.status === 2,
  171. 'icon-cancel': this.state.status === 3
  172. };
  173. }
  174. },
  175. methods: {
  176. loadDetail(recordId) {
  177. getOrderDetail(recordId).then(([err, res]) => {
  178. console.log('getOrderDetail', err, res);
  179. if (!err) {
  180. this.hasLoad = true;
  181. this.loadingType = -1;
  182. this.state = res;
  183. } else {
  184. this.loadingType = 3;
  185. this.loadingText = err.data.msg || '加载失败';
  186. }
  187. });
  188. },
  189. onExpressFeed() {
  190. uni.navigateTo({
  191. url: '/answer_pages/gift/express_feed?id=' + this.recordId
  192. });
  193. },
  194. onCancel() {
  195. orderCancel(this.recordId).then(([err, res]) => {
  196. console.log('orderCancel', err, res);
  197. if (!err) {
  198. this.$logic.showToast('取消成功');
  199. this.loadDetail(this.recordId);
  200. }
  201. });
  202. },
  203. onExternalLink() {
  204. uni.navigateTo({
  205. url: '/answer_pages/home/webview?url=' + encodeURIComponent(this.state.gift_data.external_link)
  206. });
  207. },
  208. onOrderList() {
  209. uni.reLaunch({
  210. url: '/answer_pages/gift/order'
  211. });
  212. },
  213. onHome() {
  214. uni.navigateTo({
  215. url: '/answer_pages/gift/index'
  216. });
  217. },
  218. onJumpGift(giftId) {
  219. uni.navigateTo({
  220. url: '/answer_pages/gift/detail?gift_id=' + giftId
  221. });
  222. }
  223. }
  224. };
  225. </script>
  226. <style lang="scss">
  227. // page {
  228. // padding-bottom: env(safe-area-inset-bottom);
  229. // background: $pq-bg-color;
  230. // }
  231. .wrap {
  232. padding-bottom: 100upx;
  233. }
  234. .state-box {
  235. height: 180upx;
  236. display: flex;
  237. align-items: center;
  238. justify-content: center;
  239. background: #fff;
  240. &.f-wait {
  241. color: #ffc300;
  242. }
  243. &.f-done {
  244. color: #da5650;
  245. }
  246. &.f-cancel {
  247. color: #666;
  248. }
  249. .iconfont {
  250. font-size: 64upx;
  251. }
  252. .s-tit {
  253. margin-left: 20upx;
  254. font-size: 50upx;
  255. font-weight: bold;
  256. }
  257. }
  258. .gift-view {
  259. margin-top: 30upx;
  260. background: #fff;
  261. padding: 30upx;
  262. display: flex;
  263. .b-left {
  264. width: 160upx;
  265. height: 160upx;
  266. image {
  267. width: 160upx;
  268. height: 160upx;
  269. }
  270. }
  271. .b-main {
  272. margin-left: 30upx;
  273. flex: 1;
  274. display: flex;
  275. flex-direction: column;
  276. .b-title {
  277. font-size: 28upx;
  278. color: #333;
  279. }
  280. .b-spec {
  281. margin-top: 20upx;
  282. display: flex;
  283. align-items: center;
  284. .s-tit {
  285. font-size: 24upx;
  286. color: #999;
  287. }
  288. .s-value {
  289. margin-left: 10upx;
  290. font-size: 24upx;
  291. color: #666;
  292. }
  293. }
  294. .b-fund {
  295. margin-top: 20upx;
  296. display: flex;
  297. align-items: baseline;
  298. .s-worth {
  299. font-size: 24upx;
  300. color: #999;
  301. }
  302. }
  303. }
  304. }
  305. .box {
  306. margin-top: 30upx;
  307. background: #fff;
  308. padding: 15upx 0;
  309. .b-row {
  310. padding: 15upx 30upx;
  311. display: flex;
  312. // justify-content: space-between;
  313. &.f-link {
  314. align-items: center;
  315. }
  316. .b-tit {
  317. font-size: 28upx;
  318. width: 180upx;
  319. color: #666;
  320. }
  321. .b-cont {
  322. width: 510upx;
  323. display: flex;
  324. align-items: center;
  325. font-size: 28upx;
  326. color: #333;
  327. }
  328. .s-copy {
  329. margin-left: 20upx;
  330. font-size: 24upx;
  331. color: #ffc300;
  332. }
  333. .s-province,
  334. .s-city,
  335. .s-area {
  336. margin-right: 10upx;
  337. }
  338. .s-phone {
  339. margin-left: 20upx;
  340. }
  341. .s-text {
  342. color: #333;
  343. font-weight: bold;
  344. }
  345. .s-btn {
  346. padding: 0 30upx;
  347. background: #ffc300;
  348. color: #fff;
  349. font-size: 24upx;
  350. height: 60upx;
  351. line-height: 60upx;
  352. border-radius: 30upx;
  353. }
  354. }
  355. }
  356. .action {
  357. margin-top: 100upx;
  358. display: flex;
  359. padding: 0 20upx;
  360. .b-home {
  361. flex: 1;
  362. height: 78upx;
  363. line-height: 78upx;
  364. text-align: center;
  365. color: #da5650;
  366. font-size: 32upx;
  367. border: 1upx solid #da5650;
  368. border-radius: 50upx;
  369. letter-spacing: 5upx;
  370. }
  371. .b-order {
  372. margin-left: 50upx;
  373. flex: 1;
  374. height: 80upx;
  375. line-height: 80upx;
  376. text-align: center;
  377. color: #fff;
  378. font-size: 32upx;
  379. background: #da5650;
  380. border-radius: 50upx;
  381. letter-spacing: 5upx;
  382. }
  383. }
  384. .navbar {
  385. position: fixed;
  386. left: 0;
  387. bottom: 0;
  388. width: 100%;
  389. height: 100upx;
  390. background: #fff;
  391. border-top: 1upx solid #f6f6f6;
  392. display: flex;
  393. align-items: center;
  394. justify-content: flex-end;
  395. border-top: 1upx solid #eee;
  396. .b-action {
  397. margin: 0 30upx;
  398. display: flex;
  399. align-items: center;
  400. .b-btn {
  401. margin-left: 20upx;
  402. background: #da5650;
  403. height: 60upx;
  404. border-radius: 30upx;
  405. padding: 0 30upx;
  406. line-height: 60upx;
  407. font-size: 26upx;
  408. color: #fff;
  409. letter-spacing: 4upx;
  410. &.f-feed {
  411. color: #fff;
  412. background: #ffc300;
  413. }
  414. &.f-cancel {
  415. color: #666;
  416. background: none;
  417. border: 2upx solid #eee;
  418. }
  419. }
  420. }
  421. }
  422. </style>