submitOrder.vue 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360
  1. <template>
  2. <view class="container">
  3. <form>
  4. <view class="tui-box">
  5. <view v-if="deliverymodearray[0]" class="acea-row">
  6. <radio-group @change="radioChange">
  7. <label v-if="ptype==2">服务方式: </label>
  8. <label v-for="(ditem,index) in deliverymodearray" :key="index">
  9. <radio :value="ditem.val" :checked="deliverymode == ditem.val" /><text>{{ditem.key}}</text>
  10. </label>
  11. </radio-group>
  12. </view>
  13. <tui-list-cell v-if="deliverymode==1 || deliverymode==3" :arrow="true" unlined :radius="true"
  14. @click="chooseAddr">
  15. <view class="tui-bg-img"></view>
  16. <view class="tui-address">
  17. <view v-if="curAddressData.address">
  18. <view class="tui-userinfo">
  19. <text class="tui-name">{{curAddressData.name}}</text>{{curAddressData.telephone}}
  20. </view>
  21. <view class="tui-addr">
  22. <text>{{curAddressData.address_default}}{{curAddressData.address}}</text>
  23. </view>
  24. </view>
  25. <view class="tui-none-addr" v-else>
  26. <image src="/static/images/location_fill.png" class="tui-addr-img" mode="widthFix"></image>
  27. <text>请选择地址</text>
  28. </view>
  29. </view>
  30. </tui-list-cell>
  31. <tui-list-cell v-if="deliverymode==2" :arrow="!sid" unlined :radius="true" @click="chooseStore">
  32. <view class="tui-bg-img"></view>
  33. <view class="tui-address">
  34. <view v-if="storeaddrData.title">
  35. <view class="tui-userinfo">
  36. <text class="tui-name">{{storeaddrData.title}}</text>
  37. </view>
  38. <view class="tui-addr">
  39. <text>{{storeaddrData.province_name}}{{storeaddrData.city_name}}{{storeaddrData.district_name}}{{storeaddrData.region_name}}</text>
  40. </view>
  41. </view>
  42. <view class="tui-none-addr" v-else>
  43. <image src="/static/images/location_fill.png" class="tui-addr-img" mode="widthFix"></image>
  44. <text>请选择门店</text>
  45. </view>
  46. </view>
  47. </tui-list-cell>
  48. <tui-list-cell v-if="deliverymode==5" :arrow="true" unlined :radius="true" @click="chooseTuanzhang">
  49. <view class="tui-bg-img"></view>
  50. <view class="tui-address">
  51. <view v-if="TuanzhangaddrData.title">
  52. <view class="tui-userinfo">
  53. <text class="tui-name">{{TuanzhangaddrData.title}}</text>
  54. </view>
  55. <view class="tui-addr">
  56. <text>{{TuanzhangaddrData.province_name}}{{TuanzhangaddrData.city_name}}{{TuanzhangaddrData.district_name}}{{TuanzhangaddrData.address}}</text>
  57. </view>
  58. </view>
  59. <view class="tui-none-addr" v-else>
  60. <image src="/static/images/location_fill.png" class="tui-addr-img" mode="widthFix"></image>
  61. <text>请选择社区自提点</text>
  62. </view>
  63. </view>
  64. </tui-list-cell>
  65. <tui-list-cell v-if="(deliverymode==1 || deliverymode==2 || deliverymode==4) && is_times==0" :arrow="true" unlined
  66. :radius="true" @click="chooseTime">
  67. <view class="tui-address">
  68. <view v-if="servicetime">
  69. <view class="tui-addr">
  70. <text>预约时间:{{servicetime}}</text>
  71. </view>
  72. </view>
  73. <view class="tui-none-addr" v-else>
  74. <text>请选择预约时间</text>
  75. </view>
  76. </view>
  77. </tui-list-cell>
  78. <view class="tui-top tui-goods-info">
  79. <block v-for="(item,index) in goodsList" :key="index">
  80. <tui-list-cell :hover="false" padding="0">
  81. <view class="tui-goods-item">
  82. <image :src="item.pic" class="tui-goods-img"></image>
  83. <view class="tui-goods-center">
  84. <view class="tui-goods-name">{{item.name}}</view>
  85. <view class="tui-goods-attr">{{item.label || ''}}</view>
  86. </view>
  87. <view class="tui-price-right">
  88. <view>¥{{item.price}}</view>
  89. <view>x{{item.skumorequantity || item.number}}</view>
  90. </view>
  91. </view>
  92. </tui-list-cell>
  93. </block>
  94. <tui-list-cell :hover="false">
  95. <view class="tui-padding tui-flex">
  96. <view>总额</view>
  97. <view>¥{{allGoodsPrice}}</view>
  98. </view>
  99. </tui-list-cell>
  100. <tui-list-cell v-if="!hasNoCoupons" :arrow="hasCoupon" :hover="hasCoupon" @click="couponShow=true">
  101. <view class="tui-padding tui-flex">
  102. <view>优惠券</view>
  103. <view :class="{'tui-color-red':hasCoupon}">{{curCouponname||"选择优惠券"}}</view>
  104. </view>
  105. </tui-list-cell>
  106. <tui-list-cell v-if="totalPayPoints>0" @tap="PayPoints">
  107. <view class="tui-item-box">
  108. <view class="tui-icon-box">
  109. <tui-icon :name="is_PayPoints==1?'square-fill':'square'" :size="26" color="#999999">
  110. </tui-icon>
  111. </view>
  112. <view class="tui-list-cell_name">可以用{{totalPayPoints}}{{lang.points}}抵扣{{totalPointsPrice}}元
  113. </view>
  114. </view>
  115. </tui-list-cell>
  116. <!--
  117. <tui-list-cell :hover="true" :arrow="true" @click="invoice">
  118. <view class="tui-padding tui-flex">
  119. <view>发票</view>
  120. <view class="tui-invoice-text">不开发票</view>
  121. </view>
  122. </tui-list-cell>
  123. -->
  124. <tui-list-cell v-if="deliverymode==3" :hover="false">
  125. <view class="tui-padding tui-flex">
  126. <view>配送费</view>
  127. <view>¥{{yunPrice}}</view>
  128. </view>
  129. </tui-list-cell>
  130. <tui-list-cell v-if="thefare" :hover="false">
  131. <view class="tui-padding tui-flex">
  132. <view>路费(距离:{{distance}}km)</view>
  133. <view> ¥{{thefare}}</view>
  134. </view>
  135. </tui-list-cell>
  136. <tui-list-cell :hover="false" :lineLeft="false" padding="0">
  137. <view class="tui-remark-box tui-padding tui-flex">
  138. <view>订单备注</view>
  139. <input type="text" @input="remarkInput" name="remark" class="tui-remark"
  140. placeholder="请输入您的要求" placeholder-class="tui-phcolor"></input>
  141. </view>
  142. </tui-list-cell>
  143. <tui-list-cell :hover="false">
  144. <view class="tui-img__title">添加图片</view>
  145. <view>
  146. <tui-upload :value="imgvalue" :limit="5" @complete="uploadresult" @remove="remove">
  147. </tui-upload>
  148. </view>
  149. </tui-list-cell>
  150. <tui-list-cell :hover="false" unlined>
  151. <view class="tui-padding tui-flex tui-total-flex">
  152. <view class="tui-flex-end tui-color-red">
  153. <view class="tui-black">合计: </view>
  154. <view class="tui-size-26">¥</view>
  155. <view class="tui-price-large">{{setyouhuijine(allGoodsAndYunPrice)}}</view>
  156. <!--<view class="tui-size-26"></view>-->
  157. </view>
  158. </view>
  159. </tui-list-cell>
  160. </view>
  161. <!--<view class="tui-top">
  162. <tui-list-cell unlined :hover="insufficient" :radius="true" :arrow="insufficient">
  163. <view class="tui-flex">
  164. <view class="tui-balance">余额支付<text class="tui-gray">(¥2020.00)</text></view>
  165. <switch color="#19be6b" class="tui-scale-small" v-show="!insufficient" />
  166. <view class="tui-pr-30 tui-light-dark" v-show="insufficient">余额不足, 去充值</view>
  167. </view>
  168. </tui-list-cell>
  169. </view>-->
  170. </view>
  171. <view class="tui-safe-area"></view>
  172. <view class="tui-tabbar">
  173. <view class="totalPrice tui-pr-20">
  174. <view class="tui-price-large tui-color-red">
  175. <text class="pricetitle">实付金额:</text>
  176. <text>¥{{setyouhuijine(setPayPoints(allGoodsAndYunPrice))}}</text>
  177. </view>
  178. <view v-if="agreement.status==1" class="agreement">
  179. <radio style="transform:scale(0.7)" @click="setagreementagree" :checked="agreementagree == 1" />
  180. <label @click="showagreementAlert">已阅并同意购买协议</label>
  181. <tui-modal :show="showagreement" custom>
  182. <view class="tui-modal-custom">
  183. <scroll-view :style="'height:'+(height-160)+'px'" scroll-y="true">
  184. <view class="tui-modal-custom-text">
  185. <text>{{agreement.content}}</text>
  186. </view>
  187. </scroll-view>
  188. <tui-button height="72rpx" :size="28" type="danger" shape="circle"
  189. @click="hideagreementAlert">同意</tui-button>
  190. </view>
  191. </tui-modal>
  192. </view>
  193. </view>
  194. <view class="paybuttbox tui-pr25 tui-flex-end">
  195. <button class="paybutt" @click="btnPay"
  196. :style="'background:'+ pagestyleconfig.appstylecolor">确认下单</button>
  197. </view>
  198. </view>
  199. <t-pay-way :show="show" :stylecolor="pagestyleconfig.appstylecolor"
  200. :amuont="setyouhuijine(setPayPoints(allGoodsAndYunPrice)) || ''" @goPay="goPay" :paymethod="paymethod"
  201. @close="popupClose"></t-pay-way>
  202. <t-select-coupons :couponList="coupons" :show="couponShow" @ChangeCoupon="ChangeCoupon"
  203. @close="couponsClose"></t-select-coupons>
  204. </form>
  205. </view>
  206. </template>
  207. <script>
  208. import tPayWay from "@/components/views/t-pay-way/t-pay-way"
  209. import tSelectCoupons from "@/components/views/t-select-coupons/t-select-coupons"
  210. import pay from '@/common/pay.js'
  211. export default {
  212. components: {
  213. tPayWay,
  214. tSelectCoupons
  215. },
  216. data() {
  217. return {
  218. lang: {},
  219. technicalId: '',
  220. sid: '',
  221. hasCoupon: true,
  222. insufficient: false,
  223. pagestyleconfig: [],
  224. show: false,
  225. couponShow: false,
  226. islogin: 1, //是否要需要登录,需要在onLoad加截 app.page.onLoad(this,e);
  227. totalPayPoints: 0,
  228. distance: 0,
  229. thefare: 0,
  230. totalPointsPrice: 0,
  231. servicetime: '',
  232. goodsList: [],
  233. combination: [],
  234. curAddressData: [],
  235. storeaddrData: [],
  236. TuanzhangaddrData: [],
  237. allGoodsPrice: 0,
  238. yunPrice: 0,
  239. allGoodsAndYunPrice: 0,
  240. remark: "",
  241. cartid: "",
  242. buynowinfoid: '',
  243. buyNowgoods: [],
  244. orderType: "", //订单类型,购物车下单或立即支付下单,默认是购物车,
  245. hasNoCoupons: true,
  246. coupons: [],
  247. selIndex: 0,
  248. coupon_type: 0, //优惠券类型
  249. discount: 0, //优惠券折扣
  250. youhuijine: 0, //优惠券金额
  251. curCoupon: null, // 当前选择使用的优惠券
  252. curCouponname: null, // 当前选择使用的优惠券
  253. allowSelfCollection: '0', // 是否允许到店自提
  254. payment: '0', //是否支持货到付款
  255. paymentType: "",
  256. deliverymode: '',
  257. deliverymodearray: {},
  258. is_times: 0,
  259. ptype: 1,
  260. paymethod: [],
  261. is_PayPoints: 0,
  262. memberPoints: 0,
  263. currency: uni.getStorageSync('currency'),
  264. tmplIds: [],
  265. showagreement: false,
  266. width: 0,
  267. height: 0,
  268. agreement: {},
  269. agreementagree: 0,
  270. orderimage: [],
  271. imgvalue: [] //初始化图片
  272. }
  273. },
  274. onLoad: function(e) {
  275. let _this = this
  276. if (e.buynowinfoid) {
  277. _this.buynowinfoid = e.buynowinfoid;
  278. }
  279. if (e.orderType) {
  280. _this.orderType = e.orderType;
  281. }
  282. _this.$request.get('Lang.getlang').then(res => {
  283. if (res.errno == 0) {
  284. _this.lang = res.data;
  285. }
  286. });
  287. _this.$request.post('config', {
  288. mo: 'pagestyle'
  289. }).then(res => {
  290. if (res.errno == 0) {
  291. _this.pagestyleconfig = res.data
  292. }
  293. });
  294. _this.$request.get('Paymethod.list').then(res => {
  295. if (res.errno == 0) {
  296. _this.paymethod = res.data;
  297. _this.paymentType = res.data[0].default;
  298. //console.log(_this.paymentType);
  299. }
  300. });
  301. _this.$request.post('Agreement.index', {
  302. code: 'userstobuy'
  303. }).then(res => {
  304. if (res.errno == 0) {
  305. _this.agreement = res.data;
  306. }
  307. });
  308. uni.getSystemInfo({
  309. success: res => {
  310. this.width = res.windowWidth;
  311. this.height = res.windowHeight;
  312. }
  313. });
  314. },
  315. onShow: function() {
  316. let _this = this
  317. _this.servicetime = uni.getStorageSync('servicetime');
  318. _this.orderinit();
  319. },
  320. methods: {
  321. orderinit() {
  322. const _this = this;
  323. let shopList = [];
  324. //立即购买下单
  325. if ("buyNow" == _this.orderType) {
  326. if (_this.buynowinfoid) {
  327. _this.$request.post('goodsbuynowinfo.getbuynowinfo', {
  328. buynowinfoid: _this.buynowinfoid
  329. }).then(res => {
  330. if (res.errno == 0) {
  331. var buyNowInfoMem = res.data;
  332. //console.log(buyNowInfoMem);
  333. _this.kjId = buyNowInfoMem.kjId;
  334. _this.technicalId = buyNowInfoMem.technicalId;
  335. _this.sid = buyNowInfoMem.sid;
  336. if (!_this.deliverymode) {
  337. _this.deliverymode = buyNowInfoMem.deliverymode;
  338. }
  339. _this.deliverymodearray = buyNowInfoMem.deliverymodearray;
  340. _this.is_times = buyNowInfoMem.is_times;
  341. _this.ptype = buyNowInfoMem.ptype;
  342. if (buyNowInfoMem && buyNowInfoMem.shopList) {
  343. //console.log(buyNowInfoMem.shopList.length);
  344. //console.log(buyNowInfoMem.shopList.combination);
  345. if (buyNowInfoMem.shopList.length > 1)
  346. if (buyNowInfoMem.shopList.combination) {
  347. shopList = buyNowInfoMem.shopList.combination;
  348. } else {
  349. if (buyNowInfoMem.shopList[0]) {
  350. shopList = buyNowInfoMem.shopList;
  351. } else {
  352. shopList[0] = buyNowInfoMem.shopList;
  353. }
  354. console.log(buyNowInfoMem.shopList.length);
  355. }
  356. else
  357. shopList[0] = buyNowInfoMem.shopList;
  358. }
  359. }
  360. _this.goodsList = shopList;
  361. _this.$config.init(function() {
  362. _this.payment = _this.$config.getConf("payment");
  363. });
  364. if (_this.deliverymode == 2) {
  365. _this.initstoreaddr();
  366. } else if (_this.deliverymode == 5) {
  367. } else {
  368. _this.initShippingAddress();
  369. }
  370. _this.initTuanzhangaddr();
  371. });
  372. }
  373. } else {
  374. //购物车下单
  375. var shopCarInfoMem = uni.getStorageSync('shopCarInfo');
  376. _this.kjId = shopCarInfoMem.kjId;
  377. if (shopCarInfoMem && shopCarInfoMem.shopList) {
  378. // shopList = shopCarInfoMem.shopList
  379. shopList = shopCarInfoMem.shopList.filter(entity => {
  380. return entity.active;
  381. });
  382. _this.deliverymode = shopList[0].deliverymode;
  383. _this.deliverymodearray = shopList[0].deliverymodearray;
  384. //console.log(shopList);
  385. }
  386. _this.goodsList = shopList;
  387. _this.$config.init(function() {
  388. _this.payment = _this.$config.getConf("payment");
  389. });
  390. if (_this.deliverymode == 2) {
  391. _this.initstoreaddr();
  392. } else if (_this.deliverymode == 5) {
  393. } else {
  394. _this.initShippingAddress();
  395. }
  396. _this.initTuanzhangaddr();
  397. }
  398. console.log(shopList);
  399. },
  400. getAuthMsg() {
  401. return new Promise(resolve => {
  402. if (this.tmplIds.length > 0) {
  403. uni.requestSubscribeMessage({
  404. tmplIds: this.tmplIds,
  405. fail(res) {
  406. console.log(res);
  407. },
  408. complete() {
  409. resolve();
  410. }
  411. });
  412. } else {
  413. resolve();
  414. }
  415. });
  416. },
  417. chooseAddr() {
  418. uni.navigateTo({
  419. url: "/pagesA/my/address/address"
  420. })
  421. },
  422. chooseStore() {
  423. if (!this.sid) {
  424. uni.navigateTo({
  425. url: "/pagesA/my/storeaddr/storeaddr"
  426. })
  427. }
  428. },
  429. chooseTuanzhang() {
  430. uni.navigateTo({
  431. url: "/pages/tuanzhang/list"
  432. })
  433. },
  434. chooseTime() {
  435. uni.navigateTo({
  436. url: "/pagesA/submitOrder/timelist?technicalId=" + this.technicalId + "&buynowinfoid=" + this.buynowinfoid,
  437. })
  438. },
  439. btnPay() {
  440. if (this.agreementagree != 1 && this.agreement.status == 1) {
  441. this.tui.toast("请仔细阅读并勾选购买协议");
  442. return;
  443. }
  444. // #ifdef MP-WEIXIN
  445. this.getAuthMsg()
  446. //#endif
  447. if (this.allGoodsAndYunPrice == 0) {
  448. this.createOrder();
  449. } else if (this.setyouhuijine(this.setPayPoints(this.allGoodsAndYunPrice)) == 0) {
  450. this.createOrder();
  451. } else {
  452. this.show = true
  453. }
  454. },
  455. popupClose() {
  456. this.show = false
  457. },
  458. couponsClose() {
  459. this.couponShow = false
  460. },
  461. invoice() {
  462. this.tui.href('/pagesA/submitOrder/invoice')
  463. },
  464. goPay(e) {
  465. if (e.paymentType) {
  466. this.paymentType = e.paymentType;
  467. }
  468. this.createOrder();
  469. },
  470. getOrdertotal: function() {
  471. var _this = this;
  472. let postData = {
  473. ptype: _this.ptype,
  474. technicalId: _this.technicalId,
  475. sid: _this.sid,
  476. cartid: _this.cartid,
  477. paymentType: _this.paymentType,
  478. };
  479. if (_this.deliverymode == 3) {
  480. postData.shipping = '1';
  481. }
  482. if (_this.curAddressData != undefined) {
  483. postData.address_id = _this.curAddressData.id;
  484. }
  485. if (_this.buyNowgoods != undefined) {
  486. if (_this.buyNowgoods.goods_id) {
  487. postData.goodsId = _this.buyNowgoods.goods_id;
  488. }
  489. if (_this.buyNowgoods.sku) {
  490. postData.sku = _this.buyNowgoods.sku;
  491. }
  492. if (_this.buyNowgoods.msid) {
  493. postData.msid = _this.buyNowgoods.msid;
  494. }
  495. if (_this.buyNowgoods.tuanid) {
  496. postData.tuanid = _this.buyNowgoods.tuanid;
  497. }
  498. if (_this.buyNowgoods.number) {
  499. postData.number = _this.buyNowgoods.number;
  500. }
  501. if (_this.buyNowgoods.is_skumore) {
  502. postData.is_skumore = _this.buyNowgoods.is_skumore;
  503. }
  504. if (_this.buyNowgoods.skumore) {
  505. postData.skumore = JSON.stringify(_this.buyNowgoods.skumore);
  506. }
  507. }
  508. if (_this.kjId) {
  509. postData.kjid = _this.kjId
  510. }
  511. if (_this.curCoupon) {
  512. postData.couponId = _this.curCoupon.id;
  513. }
  514. postData.calculate = "true";
  515. _this.$request.post('order.total', postData).then(res => {
  516. if (res.errno != 0) {
  517. uni.showModal({
  518. title: '错误',
  519. content: res.msg,
  520. showCancel: false
  521. })
  522. return;
  523. }
  524. _this.tmplIds = res.data.tmplIds;
  525. _this.totalPayPoints = res.data.totalPayPoints;
  526. _this.memberPoints = res.data.memberPoints;
  527. _this.totalPointsPrice = res.data.totalPointsPrice;
  528. _this.allGoodsPrice = res.data.amountTotle;
  529. _this.allGoodsAndYunPrice = (res.data.amountLogistics + res.data.amountTotle + res.data
  530. .thefare).toFixed(2);
  531. _this.yunPrice = res.data.amountLogistics;
  532. _this.distance = res.data.distance;
  533. _this.thefare = res.data.thefare;
  534. if (_this.allGoodsAndYunPrice == 0 && _this.totalPointsPrice == 0 && _this.totalPayPoints >
  535. 0) {
  536. if (_this.memberPoints >= _this.totalPayPoints) {
  537. _this.is_PayPoints = 1;
  538. } else {
  539. uni.showModal({
  540. title: '提示',
  541. content: '您的' + _this.lang.points + '不够!',
  542. showCancel: false
  543. })
  544. _this.is_PayPoints = 0;
  545. }
  546. }
  547. _this.getMyCoupons();
  548. return;
  549. })
  550. },
  551. createOrder: function() {
  552. var _this = this;
  553. if (_this.remark == undefined) {
  554. _this.remark = '';
  555. }
  556. let postData = {
  557. technicalId: _this.technicalId,
  558. sid: _this.sid,
  559. cartid: _this.cartid,
  560. remark: _this.remark,
  561. paymentType: _this.paymentType,
  562. orderimage: _this.orderimage
  563. };
  564. if (_this.buyNowgoods != undefined) {
  565. if (_this.buyNowgoods.goods_id) {
  566. postData.goodsId = _this.buyNowgoods.goods_id;
  567. }
  568. if (_this.buyNowgoods.combination_ids) {
  569. postData.combination_ids = _this.buyNowgoods.combination_ids;
  570. }
  571. if (_this.buyNowgoods.msid) {
  572. postData.msid = _this.buyNowgoods.msid;
  573. }
  574. if (_this.buyNowgoods.tuanid) {
  575. postData.tuanid = _this.buyNowgoods.tuanid;
  576. }
  577. if (_this.buyNowgoods.jointuanid) {
  578. postData.jointuanid = _this.buyNowgoods.jointuanid;
  579. }
  580. if (_this.buyNowgoods.sku) {
  581. postData.sku = _this.buyNowgoods.sku;
  582. }
  583. if (_this.buyNowgoods.number) {
  584. postData.number = _this.buyNowgoods.number;
  585. }
  586. if (_this.buyNowgoods.is_skumore) {
  587. postData.is_skumore = _this.buyNowgoods.is_skumore;
  588. }
  589. if (_this.buyNowgoods.skumore) {
  590. postData.skumore = JSON.stringify(_this.buyNowgoods.skumore);
  591. }
  592. }
  593. if (_this.kjId) {
  594. postData.kjid = _this.kjId
  595. }
  596. if (_this.paymentType == 0) {
  597. uni.hideLoading();
  598. uni.showModal({
  599. title: '错误',
  600. content: '请选择支付方式!',
  601. showCancel: false
  602. })
  603. return;
  604. }
  605. postData.payment = postData.paymentType;
  606. postData.is_times = _this.is_times;
  607. if (_this.deliverymode == 1) {
  608. if (_this.is_times == 0) {
  609. if (!_this.servicetime) {
  610. uni.hideLoading();
  611. uni.showModal({
  612. title: '错误',
  613. content: '请选择预约时间!',
  614. showCancel: false
  615. })
  616. return;
  617. }
  618. postData.servicetime = _this.servicetime;
  619. }
  620. postData.address_id = _this.curAddressData.id;
  621. _this.ptype = 2;
  622. }
  623. if (_this.deliverymode == 2) {
  624. if (_this.is_times == 0) {
  625. if (!_this.servicetime) {
  626. uni.hideLoading();
  627. uni.showModal({
  628. title: '错误',
  629. content: '请选择预约时间!',
  630. showCancel: false
  631. })
  632. return;
  633. }
  634. postData.servicetime = _this.servicetime;
  635. }
  636. if (!_this.storeaddrData.id) {
  637. uni.hideLoading();
  638. uni.showModal({
  639. title: '错误',
  640. content: '请选择门店!',
  641. showCancel: false
  642. })
  643. return;
  644. }
  645. if (!_this.sid) {
  646. postData.sid = _this.storeaddrData.id;
  647. }
  648. }
  649. if (_this.deliverymode == 3) {
  650. if (!_this.curAddressData.address_default) {
  651. uni.hideLoading();
  652. uni.showModal({
  653. title: '错误',
  654. content: '请先设置您的地址!',
  655. showCancel: false
  656. })
  657. return;
  658. }
  659. postData.shipping = '1';
  660. postData.address_id = _this.curAddressData.id;
  661. }
  662. if (_this.deliverymode == 5) {
  663. if (!_this.TuanzhangaddrData.id) {
  664. uni.hideLoading();
  665. uni.showModal({
  666. title: '错误',
  667. content: '请选择自提点!',
  668. showCancel: false
  669. })
  670. return;
  671. }
  672. }
  673. postData.tz_uuid = _this.TuanzhangaddrData.uuid;
  674. postData.tz_id = _this.TuanzhangaddrData.id;
  675. if (_this.curCoupon) {
  676. postData.couponId = _this.curCoupon.id;
  677. }
  678. postData.is_PayPoints = _this.is_PayPoints;
  679. postData.deliverymode = _this.deliverymode;
  680. //console.log(postData);
  681. _this.$request.post('order.create', postData).then(res => {
  682. if (res.errno != 0) {
  683. uni.showModal({
  684. title: '错误',
  685. content: res.msg,
  686. showCancel: false
  687. })
  688. return;
  689. }
  690. if ("buyNow" != _this.orderType) {
  691. // 清空购物车数据
  692. uni.removeStorageSync('shopCarInfo');
  693. }
  694. const orderid = res.data.id;
  695. const redirectUrl = "/pagesA/submitOrder/success?ptype=" + _this.ptype;
  696. if (res.data.payment_code == 'wx_pay') {
  697. console.log(res.data);
  698. pay.wxpay('order', res.data.pay_total, res.data.id, redirectUrl);
  699. } else if (res.data.payment_code == 'balance_pay') {
  700. _this.$request.post('order.pay', {
  701. orderid: orderid
  702. }).then(res => {
  703. if (res.errno == 0) {
  704. wx.showModal({
  705. title: '成功',
  706. content: '使用余额支付成功',
  707. showCancel: false,
  708. success: function(res) {
  709. wx.redirectTo({
  710. url: redirectUrl
  711. });
  712. }
  713. })
  714. _this.$request.post('message.payorder', {
  715. orderid: orderid
  716. }).then(res => {
  717. })
  718. } else {
  719. wx.showModal({
  720. title: '失败',
  721. content: res.msg,
  722. showCancel: false
  723. })
  724. }
  725. })
  726. } else if (res.data.payment_code == 'offline_pay') {
  727. _this.sam.navigateTo('/pagesA/submitOrder/offlinepayment?id=' + res.data.id);
  728. } else if (res.data.payment_code == 'delivery_pay') {
  729. _this.sam.navigateTo(redirectUrl);
  730. } else {
  731. _this.sam.navigateTo(redirectUrl);
  732. }
  733. })
  734. },
  735. initstoreaddr: function() {
  736. var _this = this;
  737. var sid = _this.sid;
  738. if (!sid && uni.getStorageSync('order_sid')) {
  739. sid = uni.getStorageSync('order_sid');
  740. }
  741. if (sid) {
  742. _this.$request.get('store.detail', {
  743. id: sid,
  744. samkey: (new Date()).valueOf()
  745. }).then(res => {
  746. if (res.errno == 0) {
  747. _this.storeaddrData = res.data;
  748. } else {
  749. _this.storeaddrData = null;
  750. }
  751. })
  752. }
  753. _this.processYunfei();
  754. },
  755. initTuanzhangaddr: function() {
  756. var _this = this;
  757. _this.sam.getCityPosition().then(res => {
  758. if (res.tz_id) {
  759. _this.$request.get('tuanzhang.detail', {
  760. id: res.tz_id,
  761. samkey: (new Date()).valueOf()
  762. }).then(res => {
  763. if (res.errno == 0) {
  764. _this.TuanzhangaddrData = res.data;
  765. } else {
  766. _this.TuanzhangaddrData = null;
  767. }
  768. })
  769. }
  770. _this.processYunfei();
  771. });
  772. },
  773. initShippingAddress: function() {
  774. var _this = this;
  775. _this.$request.get('address.default', {
  776. samkey: (new Date()).valueOf()
  777. }).then(res => {
  778. if (res.errno == 0) {
  779. _this.curAddressData = res.data;
  780. } else {
  781. _this.curAddressData = null;
  782. }
  783. _this.processYunfei();
  784. })
  785. },
  786. processYunfei: function() {
  787. var _this = this;
  788. var goodsList = this.goodsList;
  789. var cartid = "";
  790. var allGoodsPrice = 0;
  791. //推荐人id
  792. let reid = 0;
  793. let referrer_storge = uni.getStorageSync('reid');
  794. if (referrer_storge) {
  795. reid = referrer_storge;
  796. }
  797. if ("buyNow" == _this.orderType) {
  798. var buyNowgoods = goodsList[0];
  799. _this.buyNowgoods = buyNowgoods;
  800. } else {
  801. for (let i = 0; i < goodsList.length; i++) {
  802. let carShopBean = goodsList[i];
  803. allGoodsPrice += carShopBean.price * carShopBean.number;
  804. var cartidTmp = '';
  805. if (i > 0) {
  806. cartidTmp = ",";
  807. }
  808. cartidTmp += carShopBean.cart_id;
  809. cartid += cartidTmp;
  810. }
  811. }
  812. _this.cartid = cartid;
  813. _this.getOrdertotal();
  814. },
  815. getMyCoupons: function() {
  816. var _this = this;
  817. _this.$request.get('Couponreceive.submitorder', {
  818. price: _this.allGoodsAndYunPrice,
  819. samkey: (new Date()).valueOf()
  820. }).then(res => {
  821. if (res.errno == 0) {
  822. var coupons = res.data;
  823. if (coupons.length > 0) {
  824. _this.hasNoCoupons = false;
  825. _this.coupons = coupons;
  826. }
  827. }
  828. })
  829. },
  830. setyouhuijine: function(amount) {
  831. if (this.coupon_type == 10) {
  832. return (amount - this.youhuijine).toFixed(2);
  833. } else {
  834. if (this.coupon_type == 20 && this.discount) {
  835. return ((amount * this.discount) / 10).toFixed(2);
  836. }
  837. }
  838. return amount;
  839. },
  840. setPayPoints: function(amount) {
  841. if (this.is_PayPoints == 1) {
  842. return (amount - this.totalPointsPrice).toFixed(2);
  843. } else {
  844. return amount;
  845. }
  846. },
  847. PayPoints: function() {
  848. var _this = this;
  849. if (_this.is_PayPoints == 1) {
  850. _this.is_PayPoints = 0;
  851. } else {
  852. if (_this.memberPoints >= _this.totalPayPoints) {
  853. _this.is_PayPoints = 1;
  854. } else {
  855. uni.showModal({
  856. title: '提示',
  857. content: '您的' + _this.lang.points + '不够!',
  858. showCancel: false
  859. })
  860. _this.is_PayPoints = 0;
  861. }
  862. }
  863. },
  864. radioChange: function(e) {
  865. this.deliverymode = e.detail.value;
  866. console.log(this.deliverymode);
  867. this.orderinit();
  868. },
  869. ChangeCoupon: function(e) {
  870. this.couponShow = false
  871. const selIndex = e.selIndex;
  872. if (selIndex == -1) {
  873. this.youhuijine = 0;
  874. this.discount = 0;
  875. this.curCoupon = null;
  876. this.curCouponname = null;
  877. return;
  878. }
  879. this.selIndex = selIndex;
  880. this.coupon_type = this.coupons[selIndex].coupon_type;
  881. this.discount = this.coupons[selIndex].discount;
  882. this.youhuijine = this.coupons[selIndex].reduce_price;
  883. //console.log(this.coupons[selIndex]);
  884. this.curCoupon = this.coupons[selIndex];
  885. this.curCouponname = this.coupons[selIndex].name;
  886. },
  887. remarkInput: function(e) {
  888. this.remark = e.target.value;
  889. },
  890. paymentradioChange(e) {
  891. this.paymentType = e;
  892. },
  893. showagreementAlert() {
  894. this.showagreement = true;
  895. },
  896. hideagreementAlert() {
  897. this.showagreement = false;
  898. this.setagreementagree();
  899. },
  900. setagreementagree() {
  901. this.agreementagree = 1;
  902. },
  903. uploadresult: function(e) {
  904. console.log(e)
  905. this.orderimage = e.imgArr;
  906. },
  907. remove: function(e) {
  908. //移除图片
  909. //console.log(e)
  910. let index = e.index
  911. }
  912. },
  913. /**
  914. * 页面相关事件处理函数--监听用户下拉动作
  915. */
  916. onPullDownRefresh: function() {
  917. setTimeout(() => {
  918. uni.stopPullDownRefresh()
  919. }, 200);
  920. },
  921. }
  922. </script>
  923. <style>
  924. .container {
  925. padding-bottom: 98rpx;
  926. }
  927. .tui-box {
  928. padding: 20rpx 0 118rpx;
  929. box-sizing: border-box;
  930. }
  931. .tui-address {
  932. min-height: 80rpx;
  933. padding: 10rpx 0;
  934. box-sizing: border-box;
  935. position: relative;
  936. }
  937. .tui-userinfo {
  938. font-size: 30rpx;
  939. font-weight: 500;
  940. line-height: 30rpx;
  941. padding-bottom: 12rpx;
  942. }
  943. .tui-name {
  944. padding-right: 40rpx;
  945. }
  946. .tui-addr {
  947. font-size: 24rpx;
  948. word-break: break-all;
  949. padding-right: 25rpx;
  950. }
  951. .tui-addr-tag {
  952. padding: 5rpx 8rpx;
  953. flex-shrink: 0;
  954. background: #EB0909;
  955. color: #fff;
  956. display: inline-flex;
  957. align-items: center;
  958. justify-content: center;
  959. font-size: 25rpx;
  960. line-height: 25rpx;
  961. transform: scale(0.8);
  962. transform-origin: 0 center;
  963. border-radius: 6rpx;
  964. }
  965. .tui-bg-img {
  966. position: absolute;
  967. width: 100%;
  968. height: 8rpx;
  969. left: 0;
  970. top: 0;
  971. background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAL0AAAAECAMAAADszM6/AAAAOVBMVEUAAAAVqfH/fp//vWH/vWEVqfH/fp8VqfH/fp//vWEVqfH/fp8VqfH/fp//vWH/vWEVqfH/fp//vWHpE7b6AAAAEHRSTlMA6urqqlVVFRUVq6upqVZUDT4vVAAAAEZJREFUKM/t0CcOACAQRFF6r3v/w6IQJGwyDsPT882IQzQE0E3chToByjG5LwMgLZN3TQATmdypCciBya0cgOT3/h//9PgF49kd+6lTSIIAAAAASUVORK5CYII=") repeat;
  972. }
  973. .tui-top {
  974. margin-top: 20rpx;
  975. overflow: hidden;
  976. }
  977. .tui-goods-title {
  978. font-size: 28rpx;
  979. display: flex;
  980. align-items: center;
  981. }
  982. .tui-padding {
  983. box-sizing: border-box;
  984. }
  985. .tui-goods-item {
  986. width: 100%;
  987. padding: 20rpx 30rpx;
  988. box-sizing: border-box;
  989. display: flex;
  990. justify-content: space-between;
  991. }
  992. .tui-goods-img {
  993. width: 180rpx;
  994. height: 180rpx;
  995. display: block;
  996. flex-shrink: 0;
  997. }
  998. .tui-goods-center {
  999. flex: 1;
  1000. padding: 20rpx 8rpx;
  1001. box-sizing: border-box;
  1002. }
  1003. .tui-goods-name {
  1004. max-width: 310rpx;
  1005. word-break: break-all;
  1006. overflow: hidden;
  1007. text-overflow: ellipsis;
  1008. display: -webkit-box;
  1009. -webkit-box-orient: vertical;
  1010. -webkit-line-clamp: 2;
  1011. font-size: 32rpx;
  1012. line-height: 32rpx;
  1013. }
  1014. .tui-goods-attr {
  1015. font-size: 22rpx;
  1016. color: #888888;
  1017. line-height: 32rpx;
  1018. padding-top: 20rpx;
  1019. word-break: break-all;
  1020. overflow: hidden;
  1021. text-overflow: ellipsis;
  1022. display: -webkit-box;
  1023. -webkit-box-orient: vertical;
  1024. -webkit-line-clamp: 2;
  1025. }
  1026. .tui-price-right {
  1027. text-align: right;
  1028. font-size: 24rpx;
  1029. color: #888888;
  1030. line-height: 30rpx;
  1031. padding-top: 20rpx;
  1032. }
  1033. .tui-flex {
  1034. width: 100%;
  1035. display: flex;
  1036. align-items: center;
  1037. justify-content: space-between;
  1038. font-size: 26rpx;
  1039. }
  1040. .tui-total-flex {
  1041. justify-content: flex-end;
  1042. }
  1043. .tui-color-red,
  1044. .tui-invoice-text {
  1045. color: #E41F19;
  1046. padding-right: 30rpx;
  1047. }
  1048. .tui-balance {
  1049. font-size: 28rpx;
  1050. font-weight: 500;
  1051. }
  1052. .tui-black {
  1053. color: #222;
  1054. line-height: 30rpx;
  1055. }
  1056. .tui-gray {
  1057. color: #888888;
  1058. font-weight: 400;
  1059. }
  1060. .tui-light-dark {
  1061. color: #666;
  1062. }
  1063. .tui-goods-price {
  1064. display: flex;
  1065. align-items: center;
  1066. padding-top: 20rpx;
  1067. }
  1068. .tui-size-26 {
  1069. font-size: 26rpx;
  1070. line-height: 26rpx;
  1071. }
  1072. .tui-price-large {
  1073. font-size: 34rpx;
  1074. line-height: 34rpx;
  1075. font-weight: 600;
  1076. padding-left: 12rpx;
  1077. }
  1078. .tui-flex-end {
  1079. display: flex;
  1080. align-items: flex-end;
  1081. padding-right: 0;
  1082. }
  1083. .tui-phcolor {
  1084. color: #B3B3B3;
  1085. font-size: 26rpx;
  1086. }
  1087. /* #ifndef H5 */
  1088. .tui-remark-box {
  1089. padding: 22rpx 30rpx;
  1090. }
  1091. /* #endif */
  1092. /* #ifdef H5 */
  1093. .tui-remark-box {
  1094. padding: 26rpx 30rpx;
  1095. }
  1096. /* #endif */
  1097. .tui-remark {
  1098. flex: 1;
  1099. font-size: 26rpx;
  1100. padding-left: 64rpx;
  1101. }
  1102. .tui-scale-small {
  1103. transform: scale(0.8);
  1104. transform-origin: 100% center;
  1105. }
  1106. .tui-scale-small .wx-switch-input {
  1107. margin: 0 !important;
  1108. }
  1109. /* #ifdef H5 */
  1110. >>>uni-switch .uni-switch-input {
  1111. margin-right: 0 !important;
  1112. }
  1113. /* #endif */
  1114. .tui-tabbar {
  1115. width: 100%;
  1116. height: 118rpx;
  1117. background: #fff;
  1118. position: fixed;
  1119. left: 0;
  1120. bottom: 0;
  1121. display: flex;
  1122. align-items: center;
  1123. font-size: 26rpx;
  1124. box-shadow: 0 0 1px rgba(0, 0, 0, .3);
  1125. padding-bottom: env(safe-area-inset-bottom);
  1126. z-index: 996;
  1127. }
  1128. .totalPrice {
  1129. padding-top: 10rpx;
  1130. width: 70%;
  1131. }
  1132. .pricetitle {
  1133. font-size: 30rpx;
  1134. color: #333333;
  1135. }
  1136. .paybuttbox {
  1137. width: 30%;
  1138. }
  1139. .paybutt {
  1140. width: 100%;
  1141. height: 70rpx;
  1142. line-height: 70rpx;
  1143. font-size: 28rpx;
  1144. border-radius: 50rpx;
  1145. color: #ffffff;
  1146. align-items: center;
  1147. }
  1148. .agreement {
  1149. color: #666666;
  1150. padding-top: 6rpx;
  1151. }
  1152. .modal-scroll {
  1153. height: 600rpx;
  1154. }
  1155. .tui-pr-30 {
  1156. padding-right: 30rpx;
  1157. }
  1158. .tui-pr-20 {
  1159. padding-left: 20rpx;
  1160. }
  1161. .tui-none-addr {
  1162. height: 80rpx;
  1163. padding-left: 5rpx;
  1164. display: flex;
  1165. align-items: center;
  1166. }
  1167. .tui-addr-img {
  1168. width: 36rpx;
  1169. height: 46rpx;
  1170. display: block;
  1171. margin-right: 15rpx;
  1172. }
  1173. .tui-pr25 {
  1174. padding-right: 25rpx;
  1175. }
  1176. .tui-safe-area {
  1177. height: 1rpx;
  1178. padding-bottom: env(safe-area-inset-bottom);
  1179. }
  1180. .tui-pay-item__title {
  1181. width: 100%;
  1182. height: 90rpx;
  1183. display: flex;
  1184. align-items: center;
  1185. justify-content: space-between;
  1186. padding: 0 20rpx;
  1187. box-sizing: border-box;
  1188. font-size: 28rpx;
  1189. }
  1190. .tui-pay-amuont {
  1191. color: #eb0909;
  1192. font-weight: 500;
  1193. font-size: 34rpx;
  1194. }
  1195. .tui-pay-item {
  1196. width: 100%;
  1197. height: 80rpx;
  1198. display: flex;
  1199. align-items: center;
  1200. padding: 0 20rpx;
  1201. box-sizing: border-box;
  1202. font-size: 28rpx;
  1203. }
  1204. .tui-pay-logo {
  1205. width: 48rpx;
  1206. height: 48rpx;
  1207. margin-right: 15rpx;
  1208. }
  1209. .tui-radio {
  1210. margin-left: auto;
  1211. transform: scale(0.8);
  1212. transform-origin: 100% center;
  1213. }
  1214. .tui-btn-pay {
  1215. width: 100%;
  1216. padding: 68rpx 60rpx 50rpx;
  1217. box-sizing: border-box;
  1218. }
  1219. .tui-recharge {
  1220. color: #fc872d;
  1221. margin-left: auto;
  1222. padding: 12rpx 0;
  1223. }
  1224. .acea-row {
  1225. font-size: 28rpx;
  1226. padding-top: 30rpx;
  1227. padding-left: 20rpx;
  1228. height: 60rpx;
  1229. background-color: #fff;
  1230. }
  1231. .acea-row label {
  1232. padding: 10rpx;
  1233. }
  1234. .tui-item-box {
  1235. width: 100%;
  1236. display: flex;
  1237. align-items: center;
  1238. }
  1239. .tui-list-cell_name {
  1240. padding-left: 10rpx;
  1241. display: flex;
  1242. align-items: center;
  1243. justify-content: center;
  1244. }
  1245. .tui-img__title {
  1246. padding-bottom: 24rpx;
  1247. }
  1248. </style>