create.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567
  1. <template>
  2. <view v-if="fetch && fetch.order" @click="Dever.close()">
  3. <use-tabbar :tabbar="false"></use-tabbar>
  4. <!--
  5. <view class="use-area dflex-b fwb ft-base margin-t0" style="background: #f5e7e6;">
  6. <view>¥1元开通年VIP会员,尊享5大权益</view>
  7. <view class="iconfont iconjiantou-01 fs-sm ft-dark"></view>
  8. </view>-->
  9. <!-- 配送方式选择-->
  10. <view v-if="fetch.order.deliver_type && fetch.order.deliver_type == 1">
  11. <view class="dflex-b bg-white padding-sm"
  12. v-if="fetch.order.method_list && fetch.order.method_list.length > 0">
  13. <u-subsection :list="fetch.order.method_list" shape="circle" mode="subsection"
  14. :current="fetch.order.method" @change="setMethod" activeColor="#f56c6c"></u-subsection>
  15. </view>
  16. <!-- 地址区域 -->
  17. <view class="use-area dflex-b" @click="goAddress" v-if="fetch.order.is_address == 1">
  18. <view class="dflex" v-if="fetch.user.address.area_string">
  19. <view class="iconfont icondizhi- margin-right ft-main"></view>
  20. <view class="w-full dflex-wrap-w">
  21. <view class="margin-bottom-xs clamp-2">
  22. <text>{{fetch.user.address.area_string}} {{fetch.user.address.address}}</text>
  23. </view>
  24. <view>
  25. <text>{{fetch.user.address.name}}</text>
  26. <text class="margin-left">{{fetch.user.address.phone}}</text>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="dflex" v-else>
  31. <view class="iconfont icondizhi- margin-right ft-main"></view>
  32. <view class="w-full dflex-wrap-w">
  33. <view>
  34. <text>请先添加收货地址</text>
  35. </view>
  36. </view>
  37. </view>
  38. <view class="iconfont iconjiantou-01 fs-sm"></view>
  39. </view>
  40. <!-- 自提点区域 -->
  41. <view class="use-area dflex-b" v-else-if="fetch.order && fetch.order.sales_address">
  42. <view class="dflex">
  43. <view class="iconfont icondizhi- margin-right ft-main"></view>
  44. <view class="w-full dflex-wrap-w">
  45. <view class="margin-bottom-xs clamp-2">
  46. <text>门店地址:{{fetch.order.sales_address.area_string}}
  47. {{fetch.order.sales_address.address}}</text>
  48. </view>
  49. <view>
  50. <text>{{fetch.order.sales_address.name}}</text>
  51. <text class="margin-left">{{fetch.order.sales_address.mobile}}</text>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. <!-- 商品列表 -->
  58. <view class="goods-area use-area">
  59. <view class="goods-item" v-for="(item, index) in fetch.detail" :key="index">
  60. <view class="pos-r" v-if="item.pic">
  61. <image class="dflex-c border-radius-sm" :src="item.pic" mode="aspectFill"
  62. @click="Dever.pic.preview([item.pic], item.pic)" />
  63. </view>
  64. <view class="flex1 padding-left-sm">
  65. <view class="dflex">
  66. <text class="title clamp-2">{{item.name}}</text>
  67. </view>
  68. <view class="ft-dark fs-xs padding-top-xs clamp-2" v-if="item.sku_name">{{item.sku_name}} <span
  69. v-if="item.stock.num >= 0" style="margin-left:10rpx">库存:{{item.stock.num}}</span></view>
  70. <view class="pos-r dflex-b padding-top">
  71. <u-popover position="bottom" width="200px">
  72. <view class="dflex">
  73. <view class="price flex1">{{item.cash_text}}</view>
  74. <view style="margin-left:5px;display: inline-block;">
  75. <u-icon v-if="item.promotion_text" name="question-circle"></u-icon></view>
  76. </view>
  77. <template v-slot:content>
  78. <view style="color: white;">
  79. <u-parse :content="item.promotion_text"></u-parse>
  80. </view>
  81. </template>
  82. </u-popover>
  83. <u-number-box :integer="true" :step="1" :min="item.stock.num == 0 ? 0 : 1"
  84. :disabled="item.stock.num == 0" :max="item.stock.num >= 0 ? item.stock.num : 9999"
  85. v-model="item.num" @change="(e)=>operNumber(index, e)"></u-number-box>
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. <!-- 优惠券区域 -->
  91. <view class="use-area dflex-b" @click="open('coupon')" v-if="fetch.user.coupon.length > 0">
  92. <view class="dflex">
  93. <view class="iconfont __left margin-right-sm iconyouhui" style="color: #333;"></view>
  94. <text class="flex1 ws-np"
  95. style="font-size: 13px; font-weight: normal;">优惠券({{fetch.user.coupon.length}})</text>
  96. </view>
  97. <view class="dflex margin-left-xl">
  98. <text class="tip line-height-1 margin-right-xs"
  99. v-if="fetch.order.coupon_name">{{fetch.order.coupon_name}}</text>
  100. <text class="tip line-height-1 margin-right-xs ft-base"
  101. v-if="fetch.order.coupon_cash > 0">{{fetch.order.coupon_cash_text}}</text>
  102. <text class="tip line-height-1 margin-right-xs" v-else>选择优惠券</text>
  103. <view class="iconfont fs-sm iconjiantou-01" style="color: #c0c0c0;"></view>
  104. </view>
  105. </view>
  106. <u-popup :show="show.coupon" @close="close('coupon')" round="25">
  107. <!-- 优惠券区 -->
  108. <scroll-view class="popup-area border-radius-top30 coupon-area padding bg-drak"
  109. v-if="fetch && fetch.user.coupon && fetch.user.coupon.length > 0" scroll-y="true">
  110. <view class="coupon-item bg-main pos-r fs-xs" v-for="(item, index) in fetch.user.coupon" :key="index">
  111. <view class="content pos-r padding dflex-b">
  112. <view class="">
  113. <view class="margin-bottom-xs fs">{{ item.name }}</view>
  114. <view class="ft-dark">{{item.date_name}}</view>
  115. </view>
  116. <view class="tar">
  117. <view class="margin-bottom-xs price">{{ item.title }}</view>
  118. <view class="ft-dark" v-if="item.type == 3">抵扣:{{item.yue_text}}</view>
  119. <view class="ft-dark" v-else-if="item.yue_text">余额:{{item.yue_text}}</view>
  120. </view>
  121. <view class="circle l"></view>
  122. <view class="circle r"></view>
  123. </view>
  124. <view class="dflex-b">
  125. <text class="ft-dark padding-lr">{{ item.type_name }}</text>
  126. <text class="submit dflex-c border-radius-big padding-lr animated-all bg-base"
  127. @click="noUseCoupon(item)" v-if="fetch.order.user_coupon_id == item.id"
  128. style="background-color:burlywood">取消使用</text>
  129. <text class="submit dflex-c border-radius-big padding-lr animated-all bg-base"
  130. @click="useCoupon(item)" v-else>使用</text>
  131. </view>
  132. </view>
  133. </scroll-view>
  134. <view v-else class="coupon-area dflex-c">暂无优惠券</view>
  135. </u-popup>
  136. <!-- 礼品卡区域 -->
  137. <view class="use-area dflex-b" @click="open('gift')" v-if="fetch.user.gift.length > 0">
  138. <view class="dflex">
  139. <view class="iconfont __left margin-right-sm iconaixin" style="color: #333;"></view>
  140. <text class="flex1 ws-np"
  141. style="font-size: 13px; font-weight: normal;">礼品卡({{fetch.user.gift.length}})</text>
  142. </view>
  143. <view class="dflex margin-left-xl">
  144. <text class="tip line-height-1 margin-right-xs"
  145. v-if="fetch.order.gift_name">{{fetch.order.gift_name}}</text>
  146. <text class="tip line-height-1 margin-right-xs ft-base"
  147. v-if="fetch.order.gift_cash > 0">{{fetch.order.gift_cash_text}}</text>
  148. <text class="tip line-height-1 margin-right-xs" v-else>选择礼品卡</text>
  149. <view class="iconfont fs-sm iconjiantou-01" style="color: #c0c0c0;"></view>
  150. </view>
  151. </view>
  152. <u-popup :show="show.gift" @close="close('gift')" round="25">
  153. <!-- 礼品卡 -->
  154. <scroll-view class="popup-area border-radius-top30 coupon-area padding bg-drak"
  155. v-if="fetch && fetch.user.gift && fetch.user.gift.length > 0" scroll-y="true">
  156. <view class="coupon-item bg-main pos-r fs-xs" v-for="(item, index) in fetch.user.gift" :key="index">
  157. <view class="content pos-r padding dflex-b">
  158. <view class="">
  159. <view class="margin-bottom-xs fs">{{ item.name }}</view>
  160. <view class="ft-dark">{{item.date_name}}</view>
  161. </view>
  162. <view class="tar">
  163. <view class="margin-bottom-xs price">{{ item.title }}</view>
  164. <view class="ft-dark">余额:{{item.yue_text}}</view>
  165. </view>
  166. <view class="circle l"></view>
  167. <view class="circle r"></view>
  168. </view>
  169. <view class="dflex-b">
  170. <text class="ft-dark padding-lr">{{ item.type_name }}</text>
  171. <text class="submit dflex-c border-radius-big padding-lr animated-all bg-base"
  172. @click="noUseGift(item)" v-if="fetch.order.user_gift_id == item.id"
  173. style="background-color:burlywood">取消使用</text>
  174. <text class="submit dflex-c border-radius-big padding-lr animated-all bg-base"
  175. @click="useGift(item)" v-else>使用</text>
  176. </view>
  177. </view>
  178. </scroll-view>
  179. <view v-else class="coupon-area dflex-c">暂无礼品卡</view>
  180. </u-popup>
  181. <!-- 钱包 -->
  182. <view class="use-area dflex-b" @click="open('wallet')" v-if="fetch.user.wallet.yue > 0">
  183. <view class="dflex">
  184. <view class="iconfont __left margin-right-sm iconquanbudingdan-" style="color: #333;"></view>
  185. <text class="flex1 ws-np"
  186. style="font-size: 13px; font-weight: normal;">{{fetch.user.wallet.name}}({{fetch.user.wallet.yue_text}})</text>
  187. </view>
  188. <view class="dflex margin-left-xl">
  189. <text class="tip margin-right-xs ft-base"
  190. v-if="fetch.order.wallet_cash > 0">{{fetch.order.wallet_cash_text}}</text>
  191. <text class="tip margin-right-xs" v-else>选择{{fetch.user.wallet.name}}</text>
  192. <view class="iconfont fs-sm iconjiantou-01" style="color: #c0c0c0;"></view>
  193. </view>
  194. </view>
  195. <!--
  196. <u-modal :show="show.wallet" :showCancelButton="true" :closeOnClickOverlay="true"
  197. :title="fetch.user.wallet.name+` :`+fetch.user.wallet.yue_text" @confirm="useWallet" @cancel="close('wallet')"
  198. @close="close('wallet')">
  199. <view class="slot-content" style="width: 100%;">
  200. <u--input :placeholder="'请输入要抵扣的'+fetch.user.wallet.name" v-model="fetch.order.wallet_cash"
  201. type="number" border="bottom" :focus="true" clearable></u--input>
  202. </view>
  203. </u-modal>-->
  204. <u-popup mode="center" @close="close('wallet')" :show="show.wallet" round="14" :closeable="true">
  205. <view class="alert-area border-radius bg-main pos-r">
  206. <view class="dflex-b ft-dark margin-bottom-sm margin-lr-xs">
  207. <view>{{fetch.user.wallet.name}} :{{fetch.user.wallet.yue_text}}</view>
  208. </view>
  209. <view class="dflex border-radius-sm field" style="padding: 8px 7px;">
  210. <u--input :placeholder="'请输入要抵扣的'+fetch.user.wallet.name" v-model="fetch.order.wallet_cash"
  211. class="fwb fs-sm" type="number" border="none" :focus="true" clearable
  212. style="max-height: 76px; min-height: 19px; height: auto; font: initial;"></u--input>
  213. </view>
  214. <!-- 提交按钮 -->
  215. <view class="bg-base margin-top-xl tac w-full border-radius-lg padding-tb-sm" @click="useWallet">
  216. 提交
  217. </view>
  218. </view>
  219. </u-popup>
  220. <!-- 金额信息 -->
  221. <view class="use-area cash-area">
  222. <view class="dflex-b line-height-item">
  223. <view class="flex1">总价</view>
  224. <view>{{fetch.order.cash_text}}</view>
  225. </view>
  226. <view class="dflex-b line-height-item" v-if="fetch.order.coupon_cash > 0">
  227. <view class="flex1">优惠券抵扣</view>
  228. <view class="ft-base">-{{fetch.order.coupon_cash_text}}</view>
  229. </view>
  230. <view class="dflex-b line-height-item" v-if="fetch.order.gift_cash > 0">
  231. <view class="flex1">礼品卡抵扣</view>
  232. <view class="ft-base">-{{fetch.order.gift_cash_text}}</view>
  233. </view>
  234. <view class="dflex-b line-height-item" v-if="fetch.order.wallet_cash > 0">
  235. <view class="flex1">{{fetch.user.wallet.name}}抵扣</view>
  236. <view class="ft-base">-{{fetch.order.wallet_cash_text}}</view>
  237. </view>
  238. <view class="dflex-b line-height-item" v-if="fetch.rebate && fetch.rebate.buy && fetch.rebate.buy.desc">
  239. <view class="flex1">{{ fetch.rebate.buy.name }}</view>
  240. <view class="ft-base">{{ fetch.rebate.buy.desc }}</view>
  241. </view>
  242. <view class="dflex-b line-height-item" v-if="fetch.rebate && fetch.rebate.buy && fetch.rebate.share.desc">
  243. <view class="flex1">{{ fetch.rebate.share.name }}</view>
  244. <view class="ft-base">{{ fetch.rebate.share.desc }}</view>
  245. </view>
  246. <!--
  247. <view class="dflex-b line-height-item" v-if="fetch.rebate && fetch.rebate.rule.length <= 0">
  248. <view class="flex1">购买立返</view>
  249. <view class="ft-base">无</view>
  250. </view>
  251. -->
  252. </view>
  253. <!-- 积分信息 -->
  254. <!--
  255. <view class="use-area">
  256. <view class="rebate-line" v-if="fetch.rebate && fetch.rebate.buy && fetch.rebate.buy.desc">
  257. <text class="icon icon-jifen">🎁</text>
  258. <text class="label">{{ fetch.rebate.buy.name }}:</text>
  259. <text class="value">{{ fetch.rebate.buy.desc }}</text>
  260. </view>
  261. <view class="rebate-line" v-if="fetch.rebate && fetch.rebate.share && fetch.rebate.share.desc">
  262. <text class="icon icon-yongjin">💰</text>
  263. <text class="label">{{ fetch.rebate.share.name }}:</text>
  264. <text class="value">{{ fetch.rebate.share.desc }}</text>
  265. </view>
  266. </view>
  267. -->
  268. <!-- 备注 -->
  269. <view class="use-area">
  270. <view class="margin-right-xl">备注</view>
  271. <textarea class="bg-drak w-full border-radius-sm margin-top-sm padding fs-sm" placeholder="请填写备注"
  272. maxlength="200" style=" min-height: 70px;
  273. height: auto;" :value="data.remark" />
  274. </view>
  275. <!-- 底部安全距离占位 -->
  276. <view class="w-full safe-area-inset-bottom" style="height: 57px;"></view>
  277. <!-- 提交区域 -->
  278. <view class="oper-area pos-f pos-b-full w-full dflex-b bg-main safe-area-inset-bottom padding-lr-sm">
  279. <u-popover position="right" width="200px">
  280. <text class="fs-sm">实付款</text>
  281. <text class="price margin-left-sm fs-xl">{{fetch.order.pay_cash_text}}</text>
  282. <view style="display:inline-block; margin-left:5px;">
  283. <u-icon name="question-circle"></u-icon>
  284. </view>
  285. <template v-slot:content>
  286. <view style="color: white;">
  287. <u-parse :content="fetch.order.score_tip"></u-parse>
  288. </view>
  289. </template>
  290. </u-popover>
  291. <view>
  292. <u-button class="submit dflex-c border-radius-big padding-lr animated-all bg-base fs-30" type="error" shape="circle" @click="act" :disabled="data.submit" :loading="data.submit" text="提交订单"></u-button>
  293. </view>
  294. </view>
  295. </view>
  296. </template>
  297. <script>
  298. import Pay from '@/lib/dever/pay.js'
  299. export default {
  300. data() {
  301. return {
  302. fetch: {},
  303. // 类型
  304. type: 'source',
  305. // 弹窗展示
  306. show: {
  307. coupon: false,
  308. gift: false,
  309. wallet: false,
  310. },
  311. // 请求数据
  312. data: {
  313. type_id: 0,
  314. detail: '',
  315. coupon_id: 0,
  316. gift_id: 0,
  317. wallet: 0,
  318. remark: '',
  319. submit: false,
  320. },
  321. };
  322. },
  323. onShow() {
  324. var options = this.Dever.data('detail');
  325. if (options && options.detail && options.type && options.type_id) {
  326. this.type = options.type;
  327. this.data.type_id = options.type_id;
  328. this.data.detail = JSON.stringify(options.detail);
  329. this.data.jump = options.jump;
  330. if (options.address_id) {
  331. this.data.address_id = options.address_id;
  332. }
  333. } else {
  334. this.Dever.alert('参数错误');
  335. return this.Dever.goHome();
  336. }
  337. this.loadData();
  338. },
  339. methods: {
  340. loadData() {
  341. this.DeverApi.get(this, this.type + '.payConfirm', this.data, res => {
  342. if (this.fetch.order.wallet_cash <= 0) {
  343. this.fetch.order.wallet_cash = '';
  344. }
  345. });
  346. },
  347. // 设置配送方式
  348. setMethod(e) {
  349. this.data.method = e
  350. this.loadData();
  351. },
  352. noUseCoupon(item) {
  353. this.data.coupon_id = -1;
  354. this.loadData();
  355. this.close('coupon');
  356. },
  357. useCoupon(item) {
  358. this.data.coupon_id = item.id;
  359. this.loadData();
  360. this.close('coupon');
  361. },
  362. noUseGift(item) {
  363. this.data.gift_id = -1;
  364. this.loadData();
  365. this.close('gift');
  366. },
  367. useGift(item) {
  368. this.data.gift_id = item.id;
  369. this.loadData();
  370. this.close('gift');
  371. },
  372. useWallet() {
  373. if (this.fetch.order.wallet_cash >= 0) {
  374. this.data.wallet = this.fetch.order.wallet_cash;
  375. this.loadData();
  376. }
  377. this.close('wallet');
  378. },
  379. operNumber(index, e) {
  380. var detail = JSON.parse(this.data.detail);
  381. if (detail[index].num != e.value) {
  382. detail[index].num = e.value
  383. this.data.detail = JSON.stringify(detail);
  384. var options = this.Dever.data('detail');
  385. options.detail = JSON.parse(this.data.detail);
  386. this.Dever.data('detail', options);
  387. this.loadData();
  388. }
  389. },
  390. async act() {
  391. if (this.fetch.order.deliver_type && this.fetch.order.deliver_type == 1 && this.fetch.order.is_address ==
  392. 1) {
  393. if (!this.fetch.user.address.area_string) {
  394. return this.Dever.alert('请先添加收货地址');
  395. }
  396. }
  397. if (this.Dever.env == 5) {
  398. const loginRes = await new Promise((resolve, reject) => {
  399. uni.login({
  400. provider: this.Dever.platform,
  401. success: resolve,
  402. fail: reject
  403. })
  404. })
  405. this.data.applet_code = loginRes.code
  406. }
  407. this.DeverApi.post(this.type + '.pay', this.data, r => {
  408. if (typeof r.pay == 'boolean') {
  409. if (r.pay) {
  410. this.yes(r)
  411. } else {
  412. this.Dever.alert('下单失败');
  413. }
  414. } else {
  415. Pay.payment(r.order_num, r.pay, res => {
  416. this.Dever.success('支付成功', () => {
  417. this.yes(r)
  418. })
  419. }, err => {
  420. this.Dever.alert('支付失败', () => {
  421. this.yes(r)
  422. })
  423. })
  424. }
  425. });
  426. },
  427. yes(r) {
  428. var jump = this.data.jump;
  429. this.Dever.data('detail', 'del');
  430. if (jump.indexOf('order/info') != -1) {
  431. this.Dever.location(jump + '?id=' + r.order_id, 'go')
  432. } else {
  433. this.Dever.location(jump, 'go')
  434. }
  435. },
  436. open(key) {
  437. this.show[key] = true;
  438. },
  439. close(key) {
  440. this.show[key] = false;
  441. },
  442. goAddress() {
  443. var id = 0;
  444. if (this.fetch.order.address_id) {
  445. id = this.fetch.order.address_id;
  446. }
  447. this.Dever.location('user/address/list?id=' + id + '&refer=order/create');
  448. }
  449. }
  450. };
  451. </script>
  452. <style lang="scss">
  453. .score {
  454. margin-right: 10rpx;
  455. }
  456. .use-area {
  457. padding: 28rpx;
  458. }
  459. .goods-area {
  460. .goods-item {
  461. display: flex;
  462. .title {
  463. height: 68rpx;
  464. }
  465. image {
  466. flex-shrink: 0;
  467. width: 86px;
  468. height: 86px;
  469. }
  470. }
  471. }
  472. .oper-area {
  473. padding: 28rpx;
  474. .submit {
  475. height: 66rpx;
  476. }
  477. }
  478. .cash-area {
  479. .dflex-b:not(:first-child) {
  480. padding-top: 20rpx;
  481. }
  482. }
  483. /* 全局样式或加 ::v-deep,如果是 scoped 样式 */
  484. ::v-deep .rich-table th,
  485. ::v-deep .rich-table td {
  486. text-align: left;
  487. /* 左对齐 */
  488. }
  489. .rebate-info {
  490. margin-top: 8rpx;
  491. font-size: 24rpx;
  492. color: #555;
  493. }
  494. .rebate-line {
  495. display: flex;
  496. align-items: center;
  497. margin-bottom: 4rpx;
  498. }
  499. .rebate-line .icon {
  500. margin-right: 6rpx;
  501. }
  502. .rebate-line .label {
  503. color: #999;
  504. margin-right: 4rpx;
  505. }
  506. .rebate-line .value {
  507. color: #e64340;
  508. font-weight: bold;
  509. }
  510. </style>