order-shop.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <view class="order-shop">
  3. <view class="m-l-20">
  4. <shop-title :shop="{shop_name:item.shop_name}" :is-link="false"></shop-title>
  5. </view>
  6. <view class="order-goods">
  7. <order-goods :list="item.goods"></order-goods>
  8. </view>
  9. <view class="item flex row-between" @tap="onShowCoupon" v-if="orderType == 0">
  10. <view>店铺优惠券</view>
  11. <view class="flex">
  12. <text class="primary" v-if="item.discount_amount">-¥{{item.discount_amount }}</text>
  13. <text v-else class="muted">请选择</text>
  14. <u-icon name="arrow-right muted" size="24" class="m-l-10"></u-icon>
  15. </view>
  16. </view>
  17. <view class="item " v-if="use_energy > 0" style="margin:10rpx auto;height:unset;">
  18. <view class="flex" style="justify-content: space-between;align-items: center;">
  19. <view class="">
  20. 使用抵用券
  21. </view>
  22. <view class="right">
  23. <view class="flex-1 m-l-20 muted" style="text-align: right;font-size: 24rpx;color: #0EB5F1;">
  24. 可用{{(item.goods[0].price * use_energy / 100 / appConfig.energyprice).toFixed(6)}}个抵用券抵扣¥{{(item.goods[0].price * use_energy / 100).toFixed(2)}}
  25. </view>
  26. <view class="int-wrap">
  27. <input type="text" placeholder="请输入抵扣数量" v-model="dNumber" @input="intEnergyNum">
  28. </view>
  29. <view class="d-price" style="font-size: 24rpx;color: #FF2C3C;text-align: center;">
  30. 抵扣{{dPrice}}元
  31. </view>
  32. </view>
  33. </view>
  34. <!-- <view class="status">
  35. <u-switch v-model="checked" @change='change'></u-switch>
  36. </view> -->
  37. </view>
  38. <view class="item flex">
  39. <view>配送方式</view>
  40. <view class="flex-1 m-l-20 muted">{{item.delivery_type_text}}</view>
  41. <view>
  42. <price-format :price="item.shipping_price"></price-format>
  43. </view>
  44. </view>
  45. <view class="item flex row-between col-top m-t-20" @tap="handleInvoice(item.shop_id)" v-if="item.open_invoice">
  46. <view>开具发票</view>
  47. <view class="invoice col-top">
  48. <text class="muted invoice--text">{{ getCurrentShopInvoice }}</text>
  49. <u-icon name="arrow-right muted" size="24" class="m-t-10 m-l-10"></u-icon>
  50. </view>
  51. </view>
  52. <view class="item flex row-between">
  53. <view>买家留言</view>
  54. <u-input v-model="remark" class="flex-1 m-l-20" :clearable="false" placeholder="请添加备注(150字以内)"></u-input>
  55. </view>
  56. <view class="item flex row-right">
  57. 共{{item.total_num || (item.goods && item.goods[0].count)}}件,合计: <price-format weight="500"
  58. :color="colorConfig.primary" :first-size="36" :second-size="36"
  59. :price="(item.total_amount - dPrice).toFixed(2) || ((item.goods && item.goods[0].team_price)- dPrice).toFixed(2)">
  60. </price-format>
  61. </view>
  62. <u-popup v-if="orderType == 0" v-model="showCoupon" border-radius="14" mode="bottom" closeable
  63. :safe-area-inset-bottom="true">
  64. <view class="p-30">
  65. <view class="title">优惠券</view>
  66. </view>
  67. <view v-if="showCoupon">
  68. <tabs :current="active" :bar-width="100" :is-scroll="false">
  69. <tab :name="'可使用优惠券 (' + usableCoupon.length + ')'">
  70. <coupon-order :list="usableCoupon" :type="0" @change="onSelectCoupon" :coupon-id="couponId">
  71. </coupon-order>
  72. </tab>
  73. <tab :name="'不可用优惠券 (' + unusableCoupon.length + ')'">
  74. <coupon-order :list="unusableCoupon" :type="1" @change="showCoupon = false"></coupon-order>
  75. </tab>
  76. </tabs>
  77. </view>
  78. </u-popup>
  79. </view>
  80. </template>
  81. <script>
  82. import {
  83. getOrderCoupon
  84. } from '@/api/activity'
  85. import {
  86. invoiceType
  87. } from "@/utils/type.js"
  88. import {
  89. mapGetters,
  90. mapActions
  91. } from 'vuex'
  92. export default {
  93. name: "order-shop",
  94. props: {
  95. item: {
  96. type: [Object, Array]
  97. },
  98. orderType: {
  99. type: Number
  100. },
  101. invoice: {
  102. type: [Object, Array]
  103. },
  104. use_energy: {}
  105. },
  106. data() {
  107. return {
  108. active: 0,
  109. remark: '',
  110. showCoupon: false,
  111. usableCoupon: [],
  112. unusableCoupon: [],
  113. usableCouponL: 0,
  114. unusableCouponL: 0,
  115. isRequest: false,
  116. couponId: '',
  117. invoiceInfo: {}, // 发票内容
  118. checked: false,
  119. dNumber: null,
  120. dPrice: 0
  121. };
  122. },
  123. computed: {
  124. ...mapGetters(['userInfo', 'appConfig']),
  125. // 获取当前发票选择显示在视图上
  126. getCurrentShopInvoice() {
  127. const invoice = this.invoiceInfo;
  128. if (invoice.name) {
  129. return `${ invoice.type == 0 ? '普通发票' : '专用发票' } - ${ invoice.header_type == 0 ? '个人' : '企业' } - ${ invoice.name }`
  130. } else {
  131. return '不开发票'
  132. }
  133. }
  134. },
  135. methods: {
  136. onShowCoupon() {
  137. if (!this.isRequest) {
  138. uni.showLoading({
  139. title: '加载中...'
  140. })
  141. this.getCoupon()
  142. } else {
  143. this.showCoupon = true
  144. }
  145. },
  146. async getCoupon() {
  147. const {
  148. item: {
  149. goods,
  150. shop_id
  151. }
  152. } = this
  153. const params = goods.map(({
  154. item_id,
  155. num,
  156. goods_id
  157. }) => ({
  158. item_id,
  159. num,
  160. goods_id
  161. }))
  162. const {
  163. data,
  164. code
  165. } = await getOrderCoupon({
  166. goods: params,
  167. shop_id: shop_id
  168. })
  169. if (code == 1) {
  170. this.isRequest = true
  171. this.usableCoupon = data.suit
  172. this.usableCouponL = data.suit.length
  173. this.unusableCoupon = data.un_suit
  174. this.unusableCouponL = data.un_suit.length
  175. this.showCoupon = true
  176. uni.hideLoading()
  177. }
  178. },
  179. // 选择发票
  180. handleInvoice(shopId) {
  181. this.$Router.push({
  182. path: '/bundle/pages/invoice/invoice',
  183. query: {
  184. shop_id: shopId,
  185. invoice: JSON.stringify(this.invoiceInfo),
  186. type: invoiceType['SETTLEMENT']
  187. }
  188. })
  189. },
  190. onSelectCoupon(e) {
  191. this.couponId = e
  192. this.$emit('changecoupon', e)
  193. this.showCoupon = false
  194. },
  195. change(status) {
  196. if (this.userInfo.is_energy == 0) {
  197. uni.showToast({
  198. title: '请先激活抵用券',
  199. icon: "none"
  200. })
  201. this.checked = false
  202. } else {
  203. this.$emit('changeEnergy', status)
  204. }
  205. },
  206. intEnergyNum(e) {
  207. let num = this.item.goods[0].price * this.use_energy / 100 / this.appConfig.energyprice
  208. let total = this.item.goods[0].price * this.use_energy / 100
  209. if (e.detail.value > num) {
  210. uni.showToast({
  211. title: '输入数量大于可抵扣数量',
  212. icon: 'none'
  213. })
  214. }
  215. this.dPrice = (total / num * e.detail.value).toFixed(2)
  216. this.$emit('intChange', this.dPrice, this.dNumber)
  217. }
  218. },
  219. watch: {
  220. remark(val) {
  221. this.$emit('changeremark', {
  222. shop_id: this.item.shop_id,
  223. remark: val
  224. })
  225. },
  226. invoice(val) {
  227. console.log(val);
  228. const res = val.filter(el => el.shop_id == this.item.shop_id)
  229. if (res.length) {
  230. this.invoiceInfo = res[0];
  231. } else {
  232. this.invoiceInfo = {};
  233. }
  234. }
  235. }
  236. }
  237. </script>
  238. <style lang="scss">
  239. .order-shop {
  240. .order-goods {
  241. border-top: $-solid-border;
  242. }
  243. .item {
  244. height: 88rpx;
  245. padding: 0 24rpx;
  246. .invoice {
  247. display: flex;
  248. &--text {
  249. width: 300rpx;
  250. text-align: right;
  251. }
  252. }
  253. .int-wrap {
  254. margin: 10rpx 0;
  255. input {
  256. border: 1px solid #f1f1f1;
  257. line-height: 50rpx;
  258. height: 50rpx;
  259. font-size: 28rpx;
  260. text-align: center;
  261. }
  262. }
  263. }
  264. }
  265. </style>