detail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <template>
  2. <app-layout>
  3. <view class="page-width detail" v-if="loading">
  4. <template v-if="gift_status == 0">
  5. <!-- 未领取 -->
  6. <view class="page-width waiting-draw" v-if="detail.wait_list && detail.wait_list.list.length > 0 && detail.type === 'direct_open'">
  7. <order
  8. sign="未领取"
  9. v-bind:order_list="detail.wait_list.list"
  10. v-bind:theme="theme"
  11. v-bind:total_price="detail.wait_list.total_price"
  12. ></order>
  13. </view>
  14. <!-- 待开奖 -->
  15. <view class="page-width waiting-draw" v-if="detail.wait_list && detail.wait_list.list.length > 0 && detail.type !== 'direct_open'">
  16. <order
  17. v-bind:order_list="detail.wait_list.list"
  18. v-bind:theme="theme"
  19. v-bind:total_price="detail.wait_list.total_price"
  20. ></order>
  21. </view>
  22. <!-- 已领取 -->
  23. <view class="page-width order" v-if="detail.convert_list && detail.convert_list.list.length > 0">
  24. <order
  25. v-bind:order_list="detail.convert_list.list"
  26. v-bind:total_price="detail.convert_list.total_price"
  27. sign="已领取"
  28. v-bind:theme="theme"
  29. ></order>
  30. </view>
  31. <!-- 已完成 -->
  32. <view class="page-width order" v-if="detail.success_list && detail.success_list.list.length > 0">
  33. <order
  34. v-bind:order_list="detail.success_list.list"
  35. v-bind:total_price="detail.success_list.total_price"
  36. sign="已完成"
  37. v-bind:theme="theme"
  38. ></order>
  39. </view>
  40. <!-- 已退款 -->
  41. <view class="page-width order" v-if="detail.refund_list && detail.refund_list.list.length > 0">
  42. <order
  43. v-bind:total_price="detail.refund_list.total_price"
  44. v-bind:order_list="detail.refund_list.list"
  45. sign="已退款"
  46. v-bind:theme="theme"
  47. ></order>
  48. </view>
  49. <!-- 订单信息 -->
  50. <view class="page-width order-information">
  51. <order-information
  52. v-bind:order_no="detail.order_no"
  53. v-bind:status="detail.status"
  54. v-bind:type="detail.type"
  55. v-bind:pay_time="detail.pay_time"
  56. v-bind:open_time="detail.open_time"
  57. v-bind:open_num="detail.open_num"
  58. ></order-information>
  59. </view>
  60. <!-- 查看领取详情 -->
  61. <view class="page-width receiving-status">
  62. <receiving-status
  63. v-bind:type="detail.type"
  64. v-bind:theme="theme"
  65. v-bind:gift_id="detail.id"
  66. v-bind:status="gift_status"
  67. v-bind:user_id="detail.id"
  68. ></receiving-status>
  69. </view>
  70. </template>
  71. <template v-else>
  72. <!-- 我获取的订单 -->
  73. <win-order
  74. @setSwitch="setSwitch"
  75. v-bind:order_list="detail.detail"
  76. v-bind:status_num="detail.status_num"
  77. v-bind:detail="detail"
  78. ></win-order>
  79. <!-- 订单信息 -->
  80. <view class="page-width order-information">
  81. <win-order-information
  82. v-bind:order_no="detail.order_no"
  83. v-bind:status="detail.status"
  84. v-bind:type="detail.giftLog.type"
  85. v-bind:pay_time="detail.giftLog.sendOrder[0].pay_time"
  86. v-bind:open_time="detail.giftLog.open_time"
  87. v-bind:open_num="detail.giftLog.open_num"
  88. ></win-order-information>
  89. </view>
  90. <!-- 物流信息 -->
  91. <view class="page-width logistics" v-if="detail.giftOrder[0].order.send_type == 1 || (detail.giftOrder[0].order.is_send == 1 && detail.giftOrder[0].order.detailExpress[0].express)">
  92. <logistics
  93. v-bind:send_type="detail.giftOrder[0].order.send_type"
  94. v-bind:store="detail.giftOrder[0].order.store"
  95. v-bind:is_send="detail.giftOrder[0].order.is_send"
  96. v-bind:express="detail.giftOrder[0].order.detailExpress[0].express"
  97. v-bind:express_no="detail.giftOrder[0].order.detailExpress[0].express_no"
  98. v-bind:customer_name="detail.giftOrder[0].order.detailExpress[0].customer_name"
  99. v-bind:cover_pic="detail.is_big_gift == 0 ? detail.giftLog.sendOrder[0].detail[0].goods.goodsWarehouse.cover_pic : '/plugins/gift/image/is_big_gift.png'"
  100. ></logistics>
  101. </view>
  102. <!-- 查看领取详情 -->
  103. <view class="page-width receiving-status">
  104. <receiving-status
  105. @receipt="receipt"
  106. v-bind:type="detail.giftLog.type"
  107. v-bind:theme="theme"
  108. v-bind:gift_id="detail.gift_id"
  109. v-bind:status="gift_status"
  110. v-bind:status_num="detail.status_num"
  111. v-bind:user_id="detail.id"
  112. v-on:setShare="setShare"
  113. v-bind:order_id="detail.giftOrder[0].order_id"
  114. :notPayOrder="detail.notPayOrder"
  115. v-bind:detail="detail.detail"
  116. ></receiving-status>
  117. </view>
  118. </template>
  119. <!-- 空白格 -->
  120. <view class="page-width empty">
  121. <app-empty-bottom
  122. backgroundColor="#f7f7f7"
  123. v-bind:height="Number(110)"
  124. ></app-empty-bottom>
  125. </view>
  126. <!-- 分享海报 -->
  127. <view class="page-width share-poster">
  128. <app-share-qr-code-poster
  129. v-bind:isHidden="false"
  130. v-model="share"
  131. ></app-share-qr-code-poster>
  132. </view>
  133. </view>
  134. </app-layout>
  135. </template>
  136. <script>
  137. import { mapState } from 'vuex';
  138. import order from '../components/detail/order.vue';
  139. import orderInformation from '../components/detail/order-information';
  140. import winOrderInformation from '../components/detail/win-order-information';
  141. import receivingStatus from '../components/detail/receiving-status.vue';
  142. import appEmptyBottom from'../../../components/basic-component/app-empty-bottom/app-empty-bottom.vue';
  143. import winOrder from '../components/detail/win-order.vue';
  144. import appShareQrCodePoster from '../../../components/page-component/app-share-qr-code-poster/app-share-qr-code-poster.vue'
  145. import logistics from '../components/detail/logistics.vue';
  146. export default {
  147. name: 'detail',
  148. data() {
  149. return {
  150. gift_id: -1,
  151. detail: {},
  152. gift_status: -1,
  153. win_detail: {},
  154. share: false,
  155. turn_no: '',
  156. loading: false,
  157. }
  158. },
  159. onLoad(options) { this.$commonLoad.onload(options);
  160. this.gift_id = options.gift_id;
  161. this.gift_status = options.status;
  162. this.$store.dispatch('gift/getConfig', this.$api.gift.config);
  163. },
  164. onShow() {
  165. let { send_detail, win_detail, join_detail } = this.$api.gift;
  166. switch (this.gift_status) {
  167. case '0':
  168. this.getDetail({
  169. url: send_detail,
  170. data: {
  171. gift_id: this.gift_id,
  172. }
  173. });
  174. break;
  175. case '1':
  176. this.getDetail({
  177. url: win_detail,
  178. data: {
  179. user_order_id: this.gift_id,
  180. },
  181. });
  182. break;
  183. case '2':
  184. this.getDetail({
  185. url: join_detail,
  186. data: {
  187. user_order_id: this.gift_id,
  188. },
  189. });
  190. break;
  191. }
  192. },
  193. // #ifdef MP
  194. onShareAppMessage(e) {
  195. if (e.from === "button") {
  196. return this.$shareAppMessage({
  197. path: '/plugins/gift/index/index',
  198. imageUrl: this.detail.is_big_gift === 0 ? this.detail.detail[0].cover_pic : this.big_gift_pic,
  199. // #ifdef MP-ALIPAY
  200. bgImgUrl:this.detail.is_big_gift === 0 ? this.detail.detail[0].cover_pic : this.big_gift_pic,
  201. // #endif
  202. title: this.detail.giftLog.bless_word,
  203. params: {
  204. gift_id: this.detail.gift_id,
  205. turn_no: this.turn_no
  206. }
  207. });
  208. }
  209. },
  210. // #endif
  211. methods: {
  212. async getDetail(data) {
  213. this.$utils.showLoading();
  214. try {
  215. const res = await this.$request({
  216. url: data.url,
  217. method: 'get',
  218. data: {
  219. ...data.data,
  220. }
  221. });
  222. this.$utils.hideLoading();
  223. if (res.code === 0) {
  224. this.detail = res.data.detail;
  225. this.loading = true;
  226. } else {
  227. uni.showModal({
  228. title: '提示',
  229. content: res.msg
  230. })
  231. }
  232. } catch (e) {
  233. this.$utils.hideLoading();
  234. throw new Error(e);
  235. }
  236. },
  237. async setShare() {
  238. this.$utils.showLoading();
  239. const res = await this.$request({
  240. url: this.$api.gift.turn,
  241. data: {
  242. id: this.gift_id
  243. }
  244. });
  245. if (res.code === 0) {
  246. this.turn_no = res.data.turn_no;
  247. this.share = true;
  248. } else {
  249. uni.showModal({
  250. title: '提示',
  251. content: res.msg
  252. })
  253. }
  254. this.$utils.hideLoading();
  255. },
  256. setSwitch(index) {
  257. this.detail.detail[index].switch = !this.detail.detail[index].switch;
  258. },
  259. receipt(order_id) {
  260. let _this = this;
  261. uni.showModal({
  262. title: '提示',
  263. content: '确认收货',
  264. success: function(res) {
  265. if (res.confirm) {
  266. _this.$request({
  267. url: _this.$api.order.confirm,
  268. data: {
  269. id: order_id,
  270. }
  271. }).then(res => {
  272. if (res.code === 0) {
  273. switch (_this.gift_status) {
  274. case '0':
  275. _this.getDetail({
  276. url: _this.$api.gift.send_detail,
  277. data: {
  278. gift_id: _this.gift_id,
  279. }
  280. });
  281. break;
  282. case '1':
  283. _this.getDetail({
  284. url: _this.$api.gift.win_detail,
  285. data: {
  286. user_order_id: _this.gift_id,
  287. },
  288. });
  289. break;
  290. case '2':
  291. _this.getDetail({
  292. url: _this.$api.gift.join_detail,
  293. data: {
  294. user_order_id: _this.gift_id,
  295. },
  296. });
  297. break;
  298. }
  299. }
  300. })
  301. }
  302. }
  303. })
  304. }
  305. },
  306. computed: {
  307. ...mapState('gift',{
  308. theme: state => state.theme,
  309. big_gift_pic: state => state.big_gift_pic,
  310. })
  311. },
  312. components: {
  313. 'order': order,
  314. 'order-information': orderInformation,
  315. 'receiving-status': receivingStatus,
  316. 'app-empty-bottom': appEmptyBottom,
  317. 'win-order': winOrder,
  318. 'win-order-information': winOrderInformation,
  319. 'app-share-qr-code-poster': appShareQrCodePoster,
  320. 'logistics': logistics,
  321. },
  322. }
  323. </script>
  324. <style scoped lang="scss">
  325. @import '../css/gift';
  326. /* 礼物详情 */
  327. .detail {
  328. position: absolute;
  329. width: 100%;
  330. min-height: 100%;
  331. background-color: #f7f7f7;
  332. }
  333. /*领取状况*/
  334. .receiving-status {
  335. margin-top: #{40upx};
  336. /*position:*/
  337. }
  338. .logistics {
  339. padding: #{24upx};
  340. }
  341. </style>