affirmSh.vue 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817
  1. <template>
  2. <view class="affirm-page">
  3. <view class="affirm-view overscroll">
  4. <form>
  5. <view class="module-com">
  6. <view class="flex-space ghs-msg">
  7. {{ghsInfo.name}} {{ ghsInfo.telephone }}
  8. <i class="iconfont icondianhua1" @tap="toPhone(ghsInfo.telephone)"></i>
  9. </view>
  10. <view class="flex ghs-msg active">
  11. {{ ghsInfo.fullAddress }}
  12. </view>
  13. </view>
  14. <view class="module-com">
  15. <view class="commodity-view">
  16. <view class="commodity-list">
  17. <view class="commodity-item" :class="{'limit-exceed-item': isLimitExceededItem(item)}" v-for="(item, index) in selectList" :key="index">
  18. <image class="item-icon" :src="item.cover" mode="aspectFill" />
  19. <view class="item-info">
  20. <view class="item-row-top">
  21. <text class="item-name">{{ item.itemName }}</text>
  22. <view class="item-price-block">
  23. <view class="item-price-line">
  24. <text class="price-current">{{ affirmCommodityPriceParts[index].main }}</text>
  25. <text v-if="affirmCommodityPriceParts[index].showStrike" class="price-original">{{ affirmCommodityPriceParts[index].strike }}</text>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="item-row-qty">
  30. <text v-if="item.bigCount > 0" class="qty-part qty-big">{{ item.bigCount }}{{ item.bigUnit }}</text>
  31. <text v-if="item.bigCount > 0 && item.smallCount > 0" class="qty-sep">·</text>
  32. <text v-if="item.smallCount > 0" class="qty-part qty-small">{{ item.smallCount }}{{ item.smallUnit }}</text>
  33. </view>
  34. <view v-if="isLimitExceededItem(item) || getLimitBuyPriceTip(item) || item.presell == 1" class="item-row-tips">
  35. <text v-if="isLimitExceededItem(item)" class="limit-exceed-tip">限购 {{ limitExceedLimitBuy }},超出 {{ limitExceedNum }}</text>
  36. <text v-if="getLimitBuyPriceTip(item)" class="limit-buy-price-tip">{{ getLimitBuyPriceTip(item) }}</text>
  37. <text v-if="item.presell == 1" class="presell-tip">预售花材下单不能退款</text>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="summary-bar">
  43. <view class="operate-view" @click="gobackEvent">
  44. <text class="iconfont icongouwuche"></text>返回修改
  45. </view>
  46. <view class="describe-view">
  47. <text class="price">共{{ allCountFun.bigLength }}扎,{{ allCountFun.weight }}公斤,合计 ¥{{ allPriceFun }}</text>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. <block v-if="ghsInfoLoaded">
  53. <view class="module-com input-line-wrap">
  54. <!-- 配送方式选择 -->
  55. <tui-list-cell class="line-cell" :hover="false" :arrow="false">
  56. <button
  57. v-for="(item, index) in visibleMethodList"
  58. :key="item.style"
  59. class="admin-button-com middle sh-method-btn"
  60. :class="[
  61. selectedMethodIndex === index ? 'blue' : 'default',
  62. item.name && item.name.length <= 2 ? 'sh-method-btn--short' : 'sh-method-btn--long'
  63. ]"
  64. @click="selectMethodByIndex(index)"
  65. >{{ item.name }}</button>
  66. </tui-list-cell>
  67. <!-- 配送方式说明 -->
  68. <tui-list-cell
  69. v-if="currentMethodExplains.length > 0"
  70. class="line-cell"
  71. :hover="false"
  72. :arrow="false"
  73. >
  74. <view>
  75. <view v-for="(exp, index) in currentMethodExplains" :key="index">
  76. <text :style="'width:100%;color:' + (Number(exp.color) === 2 ? 'red' : Number(exp.color) === 3 ? '#3385FF' : '#333333') + ';font-weight:' + (Number(exp.fontWeight) === 2 ? 'bold' : 'normal') + ';'">{{ exp.explain }}</text>
  77. </view>
  78. </view>
  79. </tui-list-cell>
  80. <!-- 物流填写/选择 -->
  81. <tui-list-cell class="line-cell" :hover="false" v-if="form.sendType == 3">
  82. <view class="tui-title">配送物流</view>
  83. <view class="wl-field-row">
  84. <input
  85. type="text"
  86. placeholder="请填写物流"
  87. v-model="form.wlName"
  88. @focus="onWlNameFocus"
  89. @input="onWlNameInput"
  90. placeholder-class="tui-placeholder"
  91. class="wl-name-input"
  92. />
  93. <button
  94. v-if="wlList.length > 0"
  95. class="admin-button-com middle wl-select-btn"
  96. @click="openWlSelect"
  97. >选择物流</button>
  98. </view>
  99. </tui-list-cell>
  100. <!-- 未达标提示:加运费/加包装费/不能下单 -->
  101. <tui-list-cell class="line-cell" :hover="false" :arrow="false" v-if="showShMethodUnMeetWarning">
  102. <view>
  103. <text style="color: red;width:100%;font-weight: bold;font-size: 30upx;text-decoration: underline;">{{ shMethodUnMeetWarningText }}</text>
  104. </view>
  105. </tui-list-cell>
  106. <!-- 配送地址状态提示 -->
  107. <tui-list-cell v-if="form.sendType == 2 && ghsInfo.openIntraCity != 1" class="line-cell" :hover="false" :arrow="false">
  108. <view>
  109. <text v-if="ghsInfo.openIntraCity == 0" style="color: #3385FF;width:100%;font-size:30upx;font-weight:bold;">运费自理或到付(请联系客服)</text>
  110. <text v-if="ghsInfo.openIntraCity == 2" style="color: red;width:100%;font-size:30upx;font-weight:bold;">跑腿配送暂不可用,请选其它方式</text>
  111. </view>
  112. </tui-list-cell>
  113. <!-- 收货地址 -->
  114. <tui-list-cell class="line-cell" :hover="false" :arrow="true" v-if="displayAddress" @click="modifyAddress">
  115. <view class="tui-title">收花地址</view>
  116. <view v-if="validAddress || ghsInfo.shopId==10649 || ghsInfo.shopId ==33668">
  117. <view style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;width:420upx;"><text>{{ shopInfo.address }}</text></view>
  118. <view v-if="shopInfo.showAddress!=shopInfo.fullAddress" style="color:#848181;"><text>{{ shopInfo.showAddress }}</text></view>
  119. </view>
  120. <view v-else>
  121. <view><text style="color:red;font-weight:bold;font-size:30upx;">请填写您的地址</text></view>
  122. </view>
  123. </tui-list-cell>
  124. <!-- 跑腿平台报价列表 -->
  125. <tui-list-cell v-if="form.sendType == 2 && currentShMethod && Number(currentShMethod.calcType) == 0 && ghsInfo.openIntraCity == 1" class="line-cell" :hover="false">
  126. <view v-if="ghsInfo.openIntraCity == 1 && deliveryQuotes.length > 0" class="delivery-quotes-container">
  127. <view class="delivery-quotes-grid">
  128. <view
  129. v-for="(item, index) in deliveryQuotes"
  130. :key="index"
  131. class="delivery-quote-item"
  132. :class="{
  133. 'active': selectedDeliveryIndex === index,
  134. 'disabled': !item.isAble,
  135. 'fixed-width': deliveryQuotes.length <= 2
  136. }"
  137. @click="selectDelivery(item, index)"
  138. >
  139. <view class="platform-name">{{ item.displayName || item.name }}</view>
  140. <view class="platform-price">{{ item.priceText }}元</view>
  141. <view v-if="item.type" class="platform-type">{{ item.type }}</view>
  142. </view>
  143. </view>
  144. </view>
  145. <view v-else style="text-align: center; padding: 20upx 0;">
  146. <text v-if="validAddress">正在获取运费...</text>
  147. <text v-else style="color:red;font-weight:bold;font-size:32upx;" @click="modifyAddress">请完善收货地址</text>
  148. </view>
  149. </tui-list-cell>
  150. <!-- 距离展示 -->
  151. <tui-list-cell class="line-cell" :hover="false" v-if="form.sendType == 2 && Number(showDistance)>0">
  152. <view class="tui-title">距离</view>
  153. <text v-if="showDistance > 100" style="color: #3385FF">{{ (showDistance/1000).toFixed(1) }}公里</text>
  154. <text v-else style="color: #3385FF">{{ showDistance }} 米</text>
  155. </tui-list-cell>
  156. <!-- 跑腿费 -->
  157. <tui-list-cell class="line-cell" :hover="false" v-if="form.sendType == 2">
  158. <view class="tui-title">跑腿费</view>
  159. <view>
  160. <text :class="isFreePt ? 'delivery-price-free' : 'delivery-price-normal'">¥{{ form.sendCost }}</text>
  161. <text v-if="isFreePt" class="free-delivery-tag">¥0</text>
  162. <!-- 展示相对当前订单最接近的一条免运费条件,点击仍可看全部 -->
  163. <text class="delivery-policy-link" @click="showDeliveryPolicyModal">{{ nearestDeliveryPolicyText }}</text>
  164. </view>
  165. </tui-list-cell>
  166. <!-- 额外费用(包装费/运费) -->
  167. <tui-list-cell class="line-cell" :hover="false" v-if="showShMethodExtraFee">
  168. <view class="tui-title">{{ shMethodExtraFeeLabel }}</view>
  169. <text style="color: #3385FF">¥{{ shMethodExtraFeeAmount }}</text>
  170. </tui-list-cell>
  171. <!-- 总金额 -->
  172. <tui-list-cell class="line-cell" :hover="false" :arrow="false">
  173. <view class="tui-title">总金额</view>
  174. <text style="color: #3385FF">¥ {{ panelTotalPrice }}</text>
  175. </tui-list-cell>
  176. <!-- 配送日期 -->
  177. <tui-list-cell class="line-cell" :hover="false" :arrow="true">
  178. <view class="tui-title">配送日期</view>
  179. <picker mode="date" :value="sendTimeWant" @change="bindDateChange" style="width:400upx;">
  180. <view class="uni-input" v-if="sendTimeWant==''" style="color:#CCCCCC;">请选日期,默认当天</view>
  181. <view class="uni-input">{{ sendTimeWant }}</view>
  182. </picker>
  183. </tui-list-cell>
  184. <!-- 备注 -->
  185. <tui-list-cell class="line-cell" :hover="false" :arrow="false">
  186. <textarea style="height: 80upx" v-model="remark" placeholder="这里写备注"/>
  187. </tui-list-cell>
  188. </view>
  189. </block>
  190. </form>
  191. </view>
  192. <view class="under-bar">
  193. <view class="price-view">
  194. <text class="price-title">合计</text>
  195. <text class="price-number">¥<text class="large">{{ modifyPrice}}</text></text>
  196. <text v-if="allReachDiscountAmount > 0" class="price-discount-tip">省¥{{ parseFloat(allReachDiscountAmount) }}</text>
  197. </view>
  198. <button class="admin-button-com blue big" @click="affirmFormSubmit(0)">提交</button>
  199. </view>
  200. <uni-popup ref="selectFlowerNumRef" background-color="#fff" type="center" :animation="false" class="class-popup-style">
  201. <view style="font-size:32upx;margin:30upx 0 10upx 30upx;width:90vw;font-weight:bold;">以下库存不足,剩余的库存,是否都要?</view>
  202. <view v-if="!$util.isEmpty(lackList)" style="display:flex;padding:10upx 20upx 20upx 30upx;height:auto;justify-content: space-between;align-items:center;flex-wrap:wrap;max-height:80vh;overflow:auto;width:90vw;font-size:32upx;">
  203. <view v-for="(item, index) in lackList" :key="index" style="width:100%;margin-top:10upx;">{{ item.name }}<text style="margin-left:20upx;font-weight:bold;color:red;">剩{{item.stock}}个</text></view>
  204. </view>
  205. <view style="width:90vw;margin:20upx 0 20upx 0;display:flex;align-items: center; justify-content: center;">
  206. <button class="admin-button-com big blue" style="width:190upx;" @click="gobackEvent">返回修改</button>
  207. <button class="admin-button-com big blue" style="width:190upx;" @click="closeRemind()">取消</button>
  208. <button class="admin-button-com big blue" style="width:190upx;" @click="affirmFormSubmit(1)">要</button>
  209. </view>
  210. </uni-popup>
  211. <uni-popup ref="deliveryPolicyPopup" type="center" background-color="#fff">
  212. <view class="policy-popup-content">
  213. <view class="policy-title">免运费条件</view>
  214. <scroll-view scroll-y="true" class="policy-scroll">
  215. <view class="policy-list">
  216. <block v-for="(item, index) in deliveryPolicyList" :key="index">
  217. <view class="policy-item">{{ item }}</view>
  218. </block>
  219. </view>
  220. </scroll-view>
  221. <view class="policy-btn" @click="closeDeliveryPolicy">知道了</view>
  222. </view>
  223. </uni-popup>
  224. <!-- 物流选择弹框:展示供货商配置的物流列表,选中后回填输入框 -->
  225. <uni-popup ref="wlPopupRef" background-color="#fff" type="center" :animation="false" class="wl-popup-wrap">
  226. <view class="wl-popup-content">
  227. <view class="wl-popup-title">请选择物流</view>
  228. <scroll-view scroll-y="true" class="wl-popup-scroll">
  229. <view class="wl-popup-list">
  230. <view v-for="(item, index) in wlList" :key="index" class="wl-popup-item">
  231. <button
  232. class="admin-button-com wl-option-btn"
  233. @click.stop="selectWl(item)"
  234. :class="{ selected: form.wlName === item.name }"
  235. >{{ item.name }}</button>
  236. </view>
  237. </view>
  238. </scroll-view>
  239. <view class="wl-popup-footer">
  240. <button class="admin-button-com big blue wl-popup-cancel-btn" @click="cancelWlSelect">取消</button>
  241. </view>
  242. </view>
  243. </uni-popup>
  244. </view>
  245. </template>
  246. <script>
  247. import TuiListCell from "@/components/plugin/list-cell";
  248. import AppAvatarModule from "@/components/module/app-avatar";
  249. import SimpleAddress from "@/components/plugin/simple-address";
  250. import AppAreaSel from "@/components/app-area-sel";
  251. import AppCustomerSel from "@/components/app-customer-sel";
  252. import productMins from "@/mixins/cgProduct";
  253. import appFormRadioBtn from "@/components/app-formRadio-btn";
  254. import appAddressGroup from "@/components/app-address-group";
  255. import appFormSend from "@/components/app-form-send";
  256. import appSendTime from "@/components/app-send-time";
  257. const formUtil = require("@/utils/formValidation.js");
  258. import AppDatePicker from "@/components/app-date-picker";
  259. import { getGhsDataApi,getWlList,calcCustomPtFee } from "@/api/ghs";
  260. import { createOrder,getShMethod } from "@/api/purchase";
  261. import { mapActions, mapGetters } from "vuex";
  262. import { shopHouponHas } from '@/api/coupon'
  263. import {currentShop} from "@/api/shop"
  264. import { allDeliveryQuotes } from "@/api/express/delivery";
  265. import ModalModule from "@/components/plugin/modal";
  266. export default {
  267. name: "affirmGhs",
  268. components: {
  269. TuiListCell,
  270. AppAvatarModule,
  271. SimpleAddress,
  272. AppAreaSel,
  273. appSendTime,
  274. AppCustomerSel,
  275. appFormRadioBtn,
  276. appAddressGroup,
  277. appFormSend,
  278. AppDatePicker,
  279. ModalModule
  280. },
  281. mixins: [productMins],
  282. data() {
  283. return {
  284. isModel: false,
  285. pageType: "cg",
  286. ghsInfo:'',
  287. sendTimeWant:'',
  288. remark:'',
  289. form: {
  290. debt:1,//结算方式 1欠款订单 0正常订单
  291. shopId: "",
  292. shopName: "",
  293. receiveProvince: "",
  294. receiveCity: "",
  295. receiveFloor: "",
  296. receiveAddress: "",
  297. receiveLong: "",
  298. receiveLat: "",
  299. sendType: 0,
  300. transType:4,
  301. sendSide: "2",
  302. sendDate: "",
  303. sendCost: 0,
  304. customId: "",
  305. product: "",
  306. hbId: '0',
  307. packCost:0,
  308. wlName:'',
  309. wlId:0
  310. },
  311. lackExpend:0,
  312. hasHb:0,
  313. selectedHb:{couponAmount:0,hbId:0,couponSelInx:0},
  314. customData: {
  315. bigCount: 0,
  316. smallCount: 0
  317. },
  318. shopInfo:{
  319. lat:'',
  320. long:'',
  321. fullAddress:'',
  322. showAddress:'',
  323. address:''
  324. },
  325. wlList:[],
  326. wlSelData: {id:0,name:''},
  327. needAddPackCost:false,
  328. transCost:[],
  329. lackList:[],
  330. limitExceedProductId:'',
  331. limitExceedLimitBuy:'',
  332. limitExceedNum:'',
  333. showDistance:0,
  334. deliveryQuotes: [], // 跑腿平台报价列表
  335. selectedDeliveryIndex: -1, // 选中的报价索引
  336. selectedDeliveryData: null, // 选中的报价数据
  337. deliveryPolicyList: [], // 包配送政策列表
  338. validAddress:false,
  339. ghsInfoLoaded: false,
  340. methodList: [],
  341. /** 当前选中的配送方式下标,默认加载后选中第一项 */
  342. selectedMethodIndex: -1
  343. };
  344. },
  345. onLoad() {
  346. this.getGhsData(this.option.id)
  347. },
  348. onShow() {
  349. if(this.selectedHb.hbId && this.selectedHb.hbId > 0) {
  350. this.form.hbId = this.selectedHb.hbId
  351. }else{
  352. this.form.hbId = 0
  353. this.hasCoupon()
  354. }
  355. //修改地址重新返回页面时,重新获取当前门店信息
  356. this.modifyAddressToggle()
  357. },
  358. computed: {
  359. ...mapGetters(["getMerchantInfo", "getLoginInfo","getDictionariesInfo"]),
  360. visibleMethodList() {
  361. return (this.methodList || [])
  362. .filter(item => Number(item.status) === 1)
  363. .sort((a, b) => Number(a.sort) - Number(b.sort))
  364. },
  365. currentShMethod() {
  366. const list = this.visibleMethodList
  367. if (this.selectedMethodIndex >= 0 && this.selectedMethodIndex < list.length) {
  368. return list[this.selectedMethodIndex]
  369. }
  370. return null
  371. },
  372. showDeliveryPolicy() {
  373. const method = this.currentShMethod
  374. if (!method) return false
  375. let rules = method.reduceRules
  376. if (typeof rules === 'string') {
  377. try {
  378. rules = JSON.parse(rules)
  379. } catch (e) {
  380. rules = []
  381. }
  382. }
  383. return Array.isArray(rules) && rules.length > 0
  384. },
  385. showShMethodExtraFee() {
  386. const method = this.currentShMethod
  387. if (!method || !this.checkShMethodBelowMinimum(method)) {
  388. return false
  389. }
  390. const unMeet = Number(method.unMeet) || 0
  391. const fee = Number(method.unMeetFee) || 0
  392. return (unMeet === 0 || unMeet === 1) && fee > 0
  393. },
  394. /**
  395. * 未达配送方式最低消费时是否展示红色提示
  396. * unMeet:0 加运费、1 加包装费、2 不能下单
  397. */
  398. showShMethodUnMeetWarning() {
  399. const method = this.currentShMethod
  400. if (!method || !this.checkShMethodBelowMinimum(method)) {
  401. return false
  402. }
  403. const unMeet = Number(method.unMeet) || 0
  404. // 不能下单:直接提示
  405. if (unMeet === 2) {
  406. return true
  407. }
  408. // 加运费 / 加包装费:有费用时提示
  409. const fee = Number(method.unMeetFee) || 0
  410. return (unMeet === 0 || unMeet === 1) && fee > 0
  411. },
  412. shMethodExtraFeeLabel() {
  413. const method = this.currentShMethod
  414. if (!method) {
  415. return "包装费"
  416. }
  417. return Number(method.unMeet) === 1 ? "包装费" : "运费"
  418. },
  419. shMethodExtraFeeAmount() {
  420. if (!this.showShMethodExtraFee) {
  421. return 0
  422. }
  423. const method = this.currentShMethod
  424. return parseFloat(Number(method && method.unMeetFee) || 0)
  425. },
  426. /** 未达标红色文案:加运费/包装费金额,或不能下单 */
  427. shMethodUnMeetWarningText() {
  428. const method = this.currentShMethod
  429. if (!method) {
  430. return ""
  431. }
  432. const tips = []
  433. const minAmount = Number(method.minAmount) || 0
  434. const minNum = Number(method.minNum) || 0
  435. if (minAmount > 0) {
  436. tips.push("未满" + minAmount + "元")
  437. }
  438. if (minNum > 0) {
  439. tips.push("未满" + minNum + "扎")
  440. }
  441. const conditionText = tips.length > 0 ? tips.join("或") : "未达最低消费"
  442. const unMeet = Number(method.unMeet) || 0
  443. // unMeet=2:未满最低消费则禁止下单
  444. if (unMeet === 2) {
  445. return conditionText + ",不能下单"
  446. }
  447. // unMeet=0 加运费;unMeet=1 加包装费,并写出具体金额
  448. const fee = parseFloat(Number(method.unMeetFee) || 0)
  449. const feeLabel = unMeet === 1 ? "包装费" : "运费"
  450. return conditionText + ",加" + feeLabel + fee + "元"
  451. },
  452. currentMethodExplains() {
  453. const method = this.currentShMethod
  454. if (!method || !Array.isArray(method.explains)) {
  455. return []
  456. }
  457. return method.explains
  458. .filter(exp => exp && exp.explain)
  459. .sort((a, b) => Number(a.sort) - Number(b.sort))
  460. },
  461. runnerFeeAmount() {
  462. if (this.isFreePt) {
  463. return 0
  464. }
  465. return Number(this.form.sendCost) || 0
  466. },
  467. panelTotalPrice() {
  468. let price = Number(this.allPriceFun) || 0
  469. price += this.runnerFeeAmount
  470. price += this.shMethodExtraFeeAmount
  471. return parseFloat(price.toFixed(2))
  472. },
  473. /** 确认页列表每行价格展示(与 selectList 顺序一致) */
  474. affirmCommodityPriceParts() {
  475. const list = this.selectList || [];
  476. return list.map(item => this.getLimitBuyPriceDisplayParts(item));
  477. },
  478. displayAddress(){
  479. if(this.form.sendType != 1){
  480. return true
  481. }
  482. if(this.ghsInfo.pfLevel && this.ghsInfo.pfLevel == 1){
  483. return true
  484. }
  485. return false
  486. },
  487. //判断是否免跑腿费
  488. isFreePt(){
  489. const method = this.currentShMethod
  490. if (!method) return false
  491. let rules = method.reduceRules
  492. if (typeof rules === 'string') {
  493. try {
  494. rules = JSON.parse(rules)
  495. } catch (e) {
  496. rules = []
  497. }
  498. }
  499. if (!Array.isArray(rules) || rules.length === 0) {
  500. return false
  501. }
  502. const flowerCount = Number(this.allCountFun.bigLength) || 0
  503. const flowerPrice = Number(this.allPriceFun) || 0
  504. const distanceInMeters = Number(this.showDistance) || 0
  505. for (const rule of rules) {
  506. const meetNum = Number(rule.meetNum) || 0
  507. const meetAmount = Number(rule.meetAmount) || 0
  508. const freeKm = Number(rule.freeKm) || 0
  509. const freeKmInMeters = freeKm * 1000
  510. if (freeKmInMeters > 0 && flowerCount >= meetNum && flowerPrice >= meetAmount && distanceInMeters <= freeKmInMeters) {
  511. return true
  512. }
  513. }
  514. return false
  515. },
  516. /**
  517. * 跑腿费旁展示文案:相对当前扎数/金额/距离,选一条最接近的免运费条件
  518. * 已满足优先;距离可达时按差额最小;都超距则选公里门槛最接近的
  519. */
  520. nearestDeliveryPolicyText() {
  521. const method = this.currentShMethod
  522. let rules = method && method.reduceRules
  523. if (typeof rules === "string") {
  524. try {
  525. rules = JSON.parse(rules)
  526. } catch (e) {
  527. rules = []
  528. }
  529. }
  530. if (!Array.isArray(rules) || rules.length === 0) {
  531. return "免运费条件"
  532. }
  533. const flowerCount = Number(this.allCountFun.bigLength) || 0
  534. const flowerPrice = Number(this.allPriceFun) || 0
  535. const distanceInMeters = Number(this.showDistance) || 0
  536. let bestText = ""
  537. let bestScore = Infinity
  538. rules.forEach(rule => {
  539. const meetNum = Number(rule.meetNum) || 0
  540. const meetAmount = Number(rule.meetAmount) || 0
  541. const freeKm = Number(rule.freeKm) || 0
  542. const freeKmInMeters = freeKm * 1000
  543. const text = this.formatReduceRuleText(rule)
  544. if (!text) {
  545. return
  546. }
  547. const numGap = Math.max(0, meetNum - flowerCount)
  548. const amountGap = Math.max(0, meetAmount - flowerPrice)
  549. const distanceOk = freeKmInMeters > 0 && distanceInMeters <= freeKmInMeters
  550. let score = 0
  551. if (numGap === 0 && amountGap === 0 && distanceOk) {
  552. // 已满足该规则,最优先展示
  553. score = 0
  554. } else if (distanceOk || freeKmInMeters <= 0) {
  555. // 距离可达:金额差 + 扎数差(1 扎按 50 元折算,便于同量纲比较接近程度)
  556. score = 1 + amountGap + numGap * 50
  557. } else {
  558. // 距离超限:排在可达规则之后,按超出米数再比差额
  559. score = 1000000 + (distanceInMeters - freeKmInMeters) + amountGap + numGap * 50
  560. }
  561. if (score < bestScore) {
  562. bestScore = score
  563. bestText = text
  564. }
  565. })
  566. return bestText || "免运费条件"
  567. },
  568. /**
  569. * 计算总金额
  570. * @returns {number}
  571. */
  572. modifyPrice(){
  573. return this.panelTotalPrice
  574. }
  575. },
  576. methods: {
  577. //初始化配送业务面板:拉取配送配置
  578. loadShMethods(ghsId) {
  579. getShMethod({ ghsId: ghsId }).then(res => {
  580. if (res.code == 1) {
  581. this.methodList = res.data && res.data.method ? res.data.method : []
  582. if (this.visibleMethodList.length > 0) {
  583. this.selectMethodByIndex(0)
  584. } else {
  585. this.selectedMethodIndex = -1
  586. }
  587. }
  588. })
  589. },
  590. checkShMethodBelowMinimum(method) {
  591. if (!method) {
  592. return false
  593. }
  594. const minAmount = Number(method.minAmount) || 0
  595. const minNum = Number(method.minNum) || 0
  596. if (minAmount <= 0 && minNum <= 0) {
  597. return false
  598. }
  599. const allPrice = Number(this.allPriceFun) || 0
  600. const bigLength = Number(this.allCountFun.bigLength) || 0
  601. return (minAmount > 0 && allPrice < minAmount) || (minNum > 0 && bigLength < minNum)
  602. },
  603. /** 按列表下标切换配送方式,并同步 sendType 供下单与条件展示 */
  604. selectMethodByIndex(index) {
  605. const list = this.visibleMethodList
  606. if (!list[index]) {
  607. return
  608. }
  609. this.selectedMethodIndex = index
  610. const sendType = Number(list[index].style)
  611. this.form.sendType = sendType
  612. //计算跑腿费,二种方式,一个通过跑腿接口,一个通过自定义计费
  613. this.calcPtFee()
  614. this.syncPackCostByMethod()
  615. },
  616. modifyAddressToggle(){
  617. currentShop().then(res=>{
  618. if(res.code == 1){
  619. this.shopInfo = res.data
  620. if(!this.$util.isEmpty(this.shopInfo.lat) && !this.$util.isEmpty(this.shopInfo.long) && !this.$util.isEmpty(this.shopInfo.address)){
  621. this.validAddress = true
  622. //计算跑腿费,二种方式,一个通过跑腿接口,一个通过自定义计费
  623. this.calcPtFee()
  624. }
  625. }
  626. })
  627. },
  628. //计算跑腿费,二种方式,一个通过跑腿接口,一个通过自定义计费
  629. calcPtFee(){
  630. if(this.form.sendType == 2 && this.validAddress && this.currentShMethod){
  631. if(Number(this.currentShMethod.calcType) == 0){
  632. this.getDeliveryQuotes()
  633. }else{
  634. this.getCustomPtFee()
  635. }
  636. }else{
  637. this.deliveryQuotes = []
  638. this.selectedDeliveryIndex = -1
  639. this.selectedDeliveryData = null
  640. this.form.sendCost = 0
  641. this.showDistance = 0
  642. }
  643. },
  644. /** 获取自定义计费跑腿费用与距离 */
  645. getCustomPtFee(){
  646. this.deliveryQuotes = []
  647. this.selectedDeliveryIndex = -1
  648. this.selectedDeliveryData = null
  649. const ghsId = this.option.id || (this.ghsInfo && this.ghsInfo.id) || 0
  650. calcCustomPtFee({ id: ghsId, sendType: 2 }).then(res => {
  651. if (res.code == 1 && res.data) {
  652. this.form.sendCost = parseFloat(res.data.sendCost) || 0
  653. this.showDistance = Number(res.data.distance) || 0
  654. } else {
  655. this.form.sendCost = 0
  656. this.showDistance = 0
  657. if (res.msg) {
  658. uni.showToast({ title: res.msg, icon: 'none' })
  659. }
  660. }
  661. }).catch(() => {
  662. this.form.sendCost = 0
  663. this.showDistance = 0
  664. uni.showToast({ title: '获取自定义运费失败', icon: 'none' })
  665. })
  666. },
  667. /**
  668. * 将单条满减规则格式化为提示文案
  669. * @param {Object} rule - meetNum/meetAmount/freeKm
  670. * @returns {string}
  671. */
  672. formatReduceRuleText(rule) {
  673. if (!rule) {
  674. return ""
  675. }
  676. const meetNum = Number(rule.meetNum) || 0
  677. const meetAmount = Number(rule.meetAmount) || 0
  678. const freeKm = Number(rule.freeKm) || 0
  679. if (meetNum > 0 && meetAmount > 0) {
  680. return `满${meetNum}扎${meetAmount}元,${freeKm}公里免运费`
  681. }
  682. if (meetNum > 0) {
  683. return `满${meetNum}扎,${freeKm}公里内免运费`
  684. }
  685. if (meetAmount > 0) {
  686. return `满${meetAmount}元,${freeKm}公里内免运费`
  687. }
  688. if (freeKm > 0) {
  689. return `${freeKm}公里内免跑腿费`
  690. }
  691. return ""
  692. },
  693. // 展示包配送政策弹窗
  694. showDeliveryPolicyModal() {
  695. this.deliveryPolicyList = []
  696. const method = this.currentShMethod
  697. if (method) {
  698. let rules = method.reduceRules
  699. if (typeof rules === 'string') {
  700. try {
  701. rules = JSON.parse(rules)
  702. } catch (e) {
  703. rules = []
  704. }
  705. }
  706. if (Array.isArray(rules) && rules.length > 0) {
  707. rules.forEach(rule => {
  708. const text = this.formatReduceRuleText(rule)
  709. if (text) {
  710. this.deliveryPolicyList.push(text)
  711. }
  712. })
  713. }
  714. }
  715. if (this.deliveryPolicyList.length === 0) {
  716. uni.showToast({
  717. title: '暂无详细配送政策',
  718. icon: 'none'
  719. })
  720. return
  721. }
  722. this.$refs.deliveryPolicyPopup.open()
  723. },
  724. syncPackCostByMethod() {
  725. const method = this.currentShMethod
  726. if (method && this.checkShMethodBelowMinimum(method)) {
  727. const unMeet = Number(method.unMeet) || 0
  728. const fee = parseFloat(Number(method.unMeetFee) || 0)
  729. if ((unMeet === 0 || unMeet === 1) && fee > 0) {
  730. this.form.packCost = fee
  731. return
  732. }
  733. }
  734. this.form.packCost = 0
  735. },
  736. /** 聚焦物流输入框时清空,便于重新填写 */
  737. onWlNameFocus() {
  738. this.form.wlName = ""
  739. this.form.wlId = 0
  740. this.wlSelData = { id: 0, name: "" }
  741. },
  742. /** 手动输入物流名称时清除已选物流 id,避免与列表选项不一致 */
  743. onWlNameInput() {
  744. this.form.wlId = 0
  745. this.wlSelData = { id: 0, name: "" }
  746. },
  747. /** 打开物流选择弹框 */
  748. openWlSelect() {
  749. if (!this.wlList.length) {
  750. uni.showToast({ title: "暂无物流可选", icon: "none" })
  751. return
  752. }
  753. this.$refs.wlPopupRef.open("center")
  754. },
  755. /** 弹框内选中物流后回填到输入框 */
  756. selectWl(item) {
  757. this.wlSelData = item || { id: 0, name: "" }
  758. this.form.wlId = this.wlSelData.id
  759. this.form.wlName = this.wlSelData.name
  760. this.$refs.wlPopupRef.close()
  761. },
  762. /** 关闭物流选择弹框 */
  763. cancelWlSelect() {
  764. this.$refs.wlPopupRef.close()
  765. },
  766. ...mapActions(["initMerchantInfo"]),
  767. closeDeliveryPolicy() {
  768. this.$refs.deliveryPolicyPopup.close()
  769. },
  770. closeRemind(){
  771. this.$refs.selectFlowerNumRef.close()
  772. this.lackList = []
  773. },
  774. // 获取跑腿平台报价
  775. getDeliveryQuotes() {
  776. this.deliveryQuotes = []
  777. this.selectedDeliveryIndex = -1
  778. this.selectedDeliveryData = null
  779. allDeliveryQuotes({
  780. ghsId: this.option.id,
  781. totalPrice: this.allPriceFun,
  782. weight: this.allCountFun.weight,
  783. selectList: this.selectList,
  784. weight: 1, // 固定重量1kg,请后期根据实际需求修改。测试过后,所有平台都能在5kg的重量下,不会产生额外费用。
  785. remark: '',
  786. }).then(res => {
  787. if (res.code === 1 && res.data && res.data.deliveryList) {
  788. // 处理报价数据
  789. this.deliveryQuotes = res.data.deliveryList
  790. .filter(item => item.isAble !== false)
  791. .map(item => {
  792. // 价格从分转换为元
  793. const price = item.price ? (item.price / 100).toFixed(1) : '0.0'
  794. // 提取平台名称(去掉括号内的内容)
  795. let displayName = item.name
  796. let bracketContent = ''
  797. if (displayName && displayName.includes('(')) {
  798. bracketContent = displayName.split('(')[1].replace(')', '')
  799. displayName = displayName.split('(')[0].trim()
  800. }
  801. //滴滴特殊处理,括号里的内容作为类型
  802. if(item.en_name == 'didi' && bracketContent != ''){
  803. item.type = bracketContent
  804. }
  805. return {
  806. ...item,
  807. displayName: displayName,
  808. priceText: price,
  809. priceNumber: parseFloat(price),
  810. bracketContent: bracketContent
  811. }
  812. })
  813. // 自动选中第一个可用的报价
  814. const firstAvailableIndex = this.deliveryQuotes.findIndex(item => item.isAble)
  815. if (firstAvailableIndex !== -1) {
  816. this.selectDelivery(this.deliveryQuotes[firstAvailableIndex], firstAvailableIndex)
  817. }
  818. } else {
  819. uni.showToast({ title: '暂无跑腿可用', icon: 'none' })
  820. }
  821. }).catch(err => {
  822. uni.showToast({ title: '没有获取到跑腿费用', icon: 'none' })
  823. })
  824. },
  825. // 选择跑腿平台
  826. selectDelivery(item, index) {
  827. this.selectedDeliveryIndex = index
  828. this.selectedDeliveryData = item
  829. this.form.sendCost = item.priceNumber
  830. this.showDistance = item.distance || 0
  831. },
  832. modifyAddress(){
  833. this.$util.pageTo({ url: '/admin/shop/add?id='+this.getLoginInfo.admin.currentShopId})
  834. },
  835. customUpdate(item) {
  836. if(item.variety == 0){
  837. if(item.stock<=0){
  838. uni.showToast({title:'没有货了',icon:'none'})
  839. return
  840. }
  841. this.customNum({ ...item, bigCount: item.bigCount, smallCount: item.smallCount })
  842. }else{
  843. this.$msg('多颜色请返回列表修改')
  844. }
  845. },
  846. //自定义数量
  847. customNum(info) {
  848. this.isModel = true;
  849. this.customData = info;
  850. this.$nextTick(()=>{
  851. this.customData.smallCount = this.customData.smallCount==0?null:this.customData.smallCount;
  852. this.customData.bigCount = this.customData.bigCount==0?null:this.customData.bigCount;
  853. this.isFocus = true;
  854. if(Number(info.smallCount)>0){
  855. this.globalUnitType = 1
  856. }else{
  857. this.globalUnitType = 0
  858. }
  859. })
  860. },
  861. modalCancel() {
  862. this.isModel = false;
  863. this.customData = {};
  864. },
  865. affirm(val) {
  866. this.isFocus = false;
  867. this.isFocusOne = false;
  868. this.$nextTick(()=>{
  869. //取消
  870. if (val.index === 0) {
  871. if(this.customData.bigCount>0 || this.customData.smallCount>0){
  872. }else{
  873. this.delAllEvent(this.customData)
  874. }
  875. this.modalCancel();
  876. return false
  877. }
  878. //二个都不是数值
  879. if(/(^[1-9]\d*$)/.test(this.customData.bigCount) == false && /(^[1-9]\d*$)/.test(this.customData.smallCount) == false){
  880. this.delAllEvent(this.customData)
  881. this.modalCancel();
  882. return;
  883. }
  884. if(/(^[1-9]\d*$)/.test(this.customData.bigCount)){
  885. if(this.customData.bigCount<=0){
  886. uni.showToast({title:"数量要大于0",icon:"none"})
  887. return;
  888. }
  889. }
  890. if(/(^[1-9]\d*$)/.test(this.customData.smallCount)){
  891. if(this.customData.smallCount<=0){
  892. uni.showToast({title:"数量要大于0",icon:"none"})
  893. return;
  894. }
  895. }
  896. const { bigCount,smallCount,bigNum,bigUnit,smallNum,smallUnit,ratio} = this.customData;
  897. const ratioNum = Number(ratio);
  898. //超过库存时 设置为库存最大值 1
  899. if (Number(bigCount) * ratioNum + Number(smallCount) > Number(bigNum) * ratioNum + Number(smallNum)) {
  900. uni.showToast({
  901. title: '库存还剩'+bigNum,
  902. icon: "none"
  903. });
  904. } else {
  905. this.updateItemEvent(this.customData)
  906. this.modalCancel()
  907. }
  908. })
  909. },
  910. init() {
  911. let that = this
  912. this.getDetailData()
  913. getWlList({id:this.option.id}).then(res=>{
  914. if(res.code == 1){
  915. that.wlList = res.data.list ? res.data.list : []
  916. }
  917. })
  918. },
  919. addEvents(item) {
  920. if(item.variety == 0){
  921. const ratio = Number(item.ratio);
  922. if(this.offVerifyRepertory){
  923. if(item.stock<=0){
  924. uni.showToast({title:'没有货了',icon:'none'})
  925. return
  926. }
  927. if (Number(this.bigCount) * ratio + Number(this.smallCount) >Number(item.bigNum) * ratio + Number(item.smallNum)) {
  928. this.$msg("库存只剩"+item.bigNum);
  929. return
  930. }
  931. }
  932. this.addEvent(item)
  933. }else{
  934. this.$msg('多颜色请返回列表修改')
  935. }
  936. },
  937. delItem(item) {
  938. if(item.variety == 0){
  939. this.delEvent(item)
  940. }else{
  941. this.$msg('多颜色请返回列表修改')
  942. }
  943. },
  944. bindDateChange(e){
  945. let date = e.detail.value
  946. this.sendTimeWant = date
  947. },
  948. toPhone(phone){
  949. uni.makePhoneCall({
  950. phoneNumber: phone
  951. });
  952. },
  953. hasCoupon() {
  954. let amount = this.allPrice
  955. shopHouponHas({amount:amount,ghsId:this.option.id}).then(res => {
  956. this.hasHb = res.data.has
  957. }).catch(err => {})
  958. },
  959. getGhsData(id) {
  960. let that = this
  961. getGhsDataApi({id:id}).then(res => {
  962. that.ghsInfo = res.data
  963. that.transCost = that.ghsInfo.transCost ? that.ghsInfo.transCost : []
  964. if(that.ghsInfo.pfLevel && that.ghsInfo.pfLevel == 1){
  965. //昆明发货到全国
  966. let packCost = 0
  967. let weight = this.allCountFun.weight ? this.allCountFun.weight : 0
  968. if (that.ghsInfo.kmPackCost && !this.$util.isEmpty(that.ghsInfo.kmPackCost)){
  969. for (const ele of that.ghsInfo.kmPackCost) {
  970. let flagWeight = ele.num?ele.num:0
  971. if(Number(flagWeight)>=Number(weight)){
  972. that.form.packCost = ele.amount?parseFloat(Number(ele.amount)):0
  973. break
  974. }
  975. }
  976. }
  977. }else{
  978. //同城配送
  979. that.form.packCost = res.data.packCost?parseFloat(res.data.packCost):0
  980. }
  981. that.lackExpend = res.data.lackExpend?parseFloat(res.data.lackExpend):0
  982. that.form.wlName = res.data.customWlName ? res.data.customWlName : ''
  983. this.loadShMethods(id)
  984. that.ghsInfoLoaded = true
  985. })
  986. },
  987. countAllPrices(e){
  988. this.allPrices = this.allPrices+Number(this.form.sendCost)
  989. },
  990. getDetailData() {
  991. let data = uni.getStorageSync("modifyShopB")
  992. if (this.$util.isEmpty(data)){
  993. return
  994. }
  995. Object.keys(this.form).forEach((i, index) => {
  996. this.form[i] = data[i];
  997. });
  998. },
  999. confirmFn(options) {
  1000. createOrder(options).then(res => {
  1001. this.resetSelectInfoByType(this.pageType);
  1002. this.resetLimitBuyInfoByType(this.pageType);
  1003. const { data: { id, orderSn } } = res;
  1004. let url = `/admin/billing/result?orderId=${id}&orderSn=${orderSn}`;
  1005. uni.redirectTo({ url: url })
  1006. });
  1007. },
  1008. affirmFormSubmit(direct){
  1009. const product = this.selectList.map(ele => {
  1010. return { productId: ele.id, bigNum: ele.bigCount, smallNum: ele.smallCount,classId:ele.classId,itemId:ele.itemId,weight:ele.weight,name:ele.name };
  1011. })
  1012. if(this.ghsInfo.pfLevel == 0){
  1013. /** 提交前校验,失败时提示并返回 false */
  1014. if (Number(this.form.sendType) === 3 && this.$util.isEmpty(this.form.wlName)) {
  1015. this.$msg("请填选物流")
  1016. return false
  1017. }
  1018. const method = this.currentShMethod
  1019. if (method && Number(method.unMeet) === 2 && this.checkShMethodBelowMinimum(method)) {
  1020. // 未满最低消费且不可下单时,提示具体需要的最低金额与数量
  1021. const minAmount = Number(method.minAmount) || 0
  1022. const minNum = Number(method.minNum) || 0
  1023. const tips = []
  1024. if (minAmount > 0) {
  1025. tips.push(`满${minAmount}元`)
  1026. }
  1027. if (minNum > 0) {
  1028. tips.push(`满${minNum}扎`)
  1029. }
  1030. const tipStr = tips.length > 0 ? `${tips.join("并且")}才能下单` : "未达到最低消费,不能下单"
  1031. this.$msg(tipStr)
  1032. return false
  1033. }
  1034. }
  1035. //多颜色
  1036. let xj = uni.getStorageSync("ghsColorItem"+this.ghsInfo.id)
  1037. let getType = this.form.sendType == 2 ? 1 : 2
  1038. //用于计划是否要包装费
  1039. let itemTotalAmount = this.allPriceFun
  1040. let params = {
  1041. getType:getType,
  1042. sendTimeWant:this.sendTimeWant,
  1043. sendType:this.form.sendType,
  1044. transType:this.form.transType,
  1045. remark:this.remark,
  1046. product:JSON.stringify(product),
  1047. ghsId:this.ghsInfo.id,
  1048. hbId: this.form.hbId,
  1049. wlName:this.form.wlName,
  1050. xj:JSON.stringify(xj),
  1051. itemTotalAmount:itemTotalAmount,
  1052. version:10,
  1053. direct:direct
  1054. }
  1055. // 如果选择了跑腿配送并且有选中的平台数据,则添加配送平台信息
  1056. if (this.form.sendType == 2 && this.selectedDeliveryData) {
  1057. params.deliveryPlatform = this.selectedDeliveryData.en_name // 平台名称
  1058. params.deliveryPrice = this.selectedDeliveryData.priceNumber // 报价金额
  1059. params.deliveryDistance = this.showDistance // 配送距离
  1060. params.deliveryBracketContent = this.selectedDeliveryData.bracketContent // 配送平台括号里的内容
  1061. }
  1062. let self = this;
  1063. self.$util.confirmModal({content:'确认提交?'}, async () => {
  1064. let pendingMsg = '';
  1065. uni.showLoading({title: '加载中',mask:true})
  1066. try {
  1067. // hideError:避免 luch-request 在 showLoading 期间 showToast 被挡住
  1068. const res = await createOrder(params, { hideError: true })
  1069. if (!res || typeof res !== 'object') {
  1070. pendingMsg = '提交失败,请重试'
  1071. return
  1072. }
  1073. if(res.code == 1){
  1074. this.limitExceedProductId = ''
  1075. this.limitExceedLimitBuy = ''
  1076. this.limitExceedNum = ''
  1077. if(res.data.hasLackError && res.data.hasLackError == 1){
  1078. this.lackList = res.data.lackList ? res.data.lackList : []
  1079. this.$refs.selectFlowerNumRef.open('center')
  1080. return
  1081. }
  1082. const {orderSn,realPrice,id} = res.data
  1083. self.pageTo({url: '/pagesPurchase/wechatPay',query:{orderSn,realPrice,id}, type: 2})
  1084. setTimeout(() => {
  1085. self.removeMemory(self.ghsInfo.id)
  1086. self.resetLimitBuyInfoByType(self.pageType)
  1087. }, 600)
  1088. return
  1089. }
  1090. if(res.code == -1 && res.data && String(res.data.productId || '') !== ''){
  1091. this.limitExceedProductId = res.data.productId ? String(res.data.productId) : ''
  1092. this.limitExceedLimitBuy = res.data.limitBuy ? String(res.data.limitBuy) : '0'
  1093. this.limitExceedNum = res.data.exceed ? String(res.data.exceed) : '0'
  1094. pendingMsg = res.msg || '累计已超出限购数'
  1095. return
  1096. }
  1097. this.limitExceedProductId = ''
  1098. this.limitExceedLimitBuy = ''
  1099. this.limitExceedNum = ''
  1100. if(res.msg){
  1101. pendingMsg = res.msg
  1102. }
  1103. } catch (err) {
  1104. pendingMsg = '提交失败,请重试'
  1105. } finally {
  1106. uni.hideLoading()
  1107. if (pendingMsg) {
  1108. // 小程序 hideLoading 后立即 showToast 可能不显示,需短暂延迟
  1109. setTimeout(() => {
  1110. self.$msg(pendingMsg)
  1111. }, 100)
  1112. }
  1113. }
  1114. })
  1115. },
  1116. isLimitExceededItem(item){
  1117. if(!item || !this.limitExceedProductId){
  1118. return false
  1119. }
  1120. return String(item.id) === String(this.limitExceedProductId)
  1121. },
  1122. numberAdd(arg1, arg2) {
  1123. var r1, r2, m, n;
  1124. try {
  1125. r1 = arg1.toString().split(".")[1].length
  1126. } catch (e) {
  1127. r1 = 0
  1128. }
  1129. try {
  1130. r2 = arg2.toString().split(".")[1].length
  1131. } catch (e) {
  1132. r2 = 0
  1133. }
  1134. m = Math.pow(10, Math.max(r1, r2))
  1135. n = (r1 >= r2) ? r1 : r2;
  1136. return ((arg1 * m + arg2 * m) / m).toFixed(n);
  1137. },
  1138. NumberSub(arg1, arg2) {
  1139. var re1, re2, m, n;
  1140. try {
  1141. re1 = arg1.toString().split(".")[1].length;
  1142. } catch (e) {
  1143. re1 = 0;
  1144. }
  1145. try {
  1146. re2 = arg2.toString().split(".")[1].length;
  1147. } catch (e) {
  1148. re2 = 0;
  1149. }
  1150. m = Math.pow(10, Math.max(re1, re2));
  1151. n = (re1 >= re2) ? re1 : re2;
  1152. return ((arg1 * m - arg2 * m) / m).toFixed(n);
  1153. },
  1154. // 表单验证
  1155. async formSubmit(e) {
  1156. try {
  1157. // 进行表单检查
  1158. let formData = this.form;
  1159. const product = this.selectList.map(ele => {
  1160. return { productId: ele.id, bigNum: ele.bigCount, smallNum: ele.smallCount };
  1161. });
  1162. formData.product = JSON.stringify(product);
  1163. if (!this.getMerchantInfo) {
  1164. await this.initMerchantInfo();
  1165. }
  1166. formData.shopId = this.getMerchantInfo.id;
  1167. let checkRes = formUtil.validation(formData, []);
  1168. // 验证通过!
  1169. if (!checkRes) {
  1170. this.confirmFn(formData);
  1171. } else {
  1172. this.$msg(checkRes);
  1173. }
  1174. } catch (error) {
  1175. console.log(999999, error);
  1176. }
  1177. },
  1178. gobackEvent() {
  1179. this.$util.pageTo({url: "/pagesPurchase/ghsProduct?id="+this.options.id,type: 2})
  1180. }
  1181. }
  1182. };
  1183. </script>
  1184. <style lang="scss" scoped>
  1185. .admin-button-com {
  1186. margin-right: 15upx;
  1187. }
  1188. .affirm-page {
  1189. position: relative;
  1190. height: 100%;
  1191. display: flex;
  1192. flex-direction: column;
  1193. /* #ifdef APP-PLUS */
  1194. padding-bottom: 100upx;
  1195. /* #endif */
  1196. .affirm-view {
  1197. flex: 1;
  1198. padding: 20upx 20upx 100upx 20upx;
  1199. background-color: #f0f2f6;
  1200. .commodity-view {
  1201. display: flex;
  1202. flex-direction: column;
  1203. .commodity-list {
  1204. padding: 20upx;
  1205. .commodity-item {
  1206. display: flex;
  1207. margin-bottom: 20upx;
  1208. &.limit-exceed-item {
  1209. border: 2upx solid #ff4d4f;
  1210. border-radius: 12upx;
  1211. padding: 12upx;
  1212. box-sizing: border-box;
  1213. }
  1214. .item-icon {
  1215. flex-shrink: 0;
  1216. width: 140upx;
  1217. height: 140upx;
  1218. border-radius: 4upx;
  1219. background-color: #f5f5f5;
  1220. }
  1221. .item-info {
  1222. display: flex;
  1223. flex-direction: column;
  1224. justify-content: flex-start;
  1225. flex: 1;
  1226. margin-left: 20upx;
  1227. min-width: 0;
  1228. .item-row-top {
  1229. display: flex;
  1230. flex-direction: row;
  1231. align-items: center;
  1232. justify-content: space-between;
  1233. width: 100%;
  1234. }
  1235. .item-name {
  1236. flex: 1;
  1237. min-width: 0;
  1238. padding-right: 16upx;
  1239. color: #333333;
  1240. font-size: 30upx;
  1241. font-weight: bold;
  1242. overflow: hidden;
  1243. white-space: nowrap;
  1244. text-overflow: ellipsis;
  1245. line-height: 1.3;
  1246. }
  1247. .item-price-block {
  1248. flex-shrink: 0;
  1249. display: flex;
  1250. flex-direction: row;
  1251. align-items: baseline;
  1252. max-width: 48%;
  1253. }
  1254. .item-price-line {
  1255. display: flex;
  1256. flex-direction: row;
  1257. align-items: baseline;
  1258. }
  1259. .price-current {
  1260. font-size: 32upx;
  1261. font-weight: bold;
  1262. color: #333333;
  1263. white-space: nowrap;
  1264. line-height: 1.2;
  1265. }
  1266. .price-original {
  1267. margin-left: 12upx;
  1268. margin-top: 0;
  1269. font-size: 29upx;
  1270. color: #999999;
  1271. text-decoration: line-through;
  1272. white-space: nowrap;
  1273. line-height: 1.2;
  1274. }
  1275. .item-row-qty {
  1276. display: flex;
  1277. flex-direction: row;
  1278. justify-content: flex-end;
  1279. align-items: center;
  1280. margin-top: 10upx;
  1281. flex-wrap: wrap;
  1282. }
  1283. .qty-sep {
  1284. margin: 0 8upx;
  1285. color: #cccccc;
  1286. font-size: 28upx;
  1287. }
  1288. .qty-part {
  1289. font-size: 28upx;
  1290. color: #666666;
  1291. }
  1292. .qty-big {
  1293. font-size: 30upx;
  1294. font-weight: bold;
  1295. color: #3385ff;
  1296. }
  1297. .item-row-tips {
  1298. display: flex;
  1299. flex-direction: column;
  1300. margin-top: 10upx;
  1301. }
  1302. .limit-exceed-tip {
  1303. margin-top: 4upx;
  1304. color: #ff4d4f;
  1305. font-size: 24upx;
  1306. font-weight: bold;
  1307. line-height: 1.45;
  1308. }
  1309. .limit-buy-price-tip {
  1310. margin-top: 4upx;
  1311. color: #ff7a00;
  1312. font-size: 24upx;
  1313. font-weight: bold;
  1314. line-height: 1.45;
  1315. }
  1316. .presell-tip {
  1317. margin-top: 4upx;
  1318. color: #e53935;
  1319. font-size: 26upx;
  1320. font-weight: bold;
  1321. line-height: 1.45;
  1322. }
  1323. }
  1324. }
  1325. }
  1326. .summary-bar {
  1327. padding: 0 20upx;
  1328. height: 90upx;
  1329. display: flex;
  1330. align-items: center;
  1331. justify-content: space-between;
  1332. border-top: 1px solid #eeeeee;
  1333. .operate-view {
  1334. display: flex;
  1335. align-items: center;
  1336. color: #3385ff;
  1337. font-size: 30upx;
  1338. font-weight:bold;
  1339. .iconfont {
  1340. margin-right: 20upx;
  1341. font-size: 40upx;
  1342. }
  1343. }
  1344. .describe-view {
  1345. display: flex;
  1346. align-items: center;
  1347. color: #333;
  1348. font-size: 24upx;
  1349. .price {
  1350. font-weight: bold;
  1351. font-size: 30upx;
  1352. }
  1353. }
  1354. }
  1355. }
  1356. .module-com {
  1357. background-color: #fff;
  1358. margin-bottom: 20upx;
  1359. border-radius: 10upx;
  1360. overflow: hidden;
  1361. padding-top: 20upx;
  1362. .ghs-msg{
  1363. padding: 0 20upx 20upx;
  1364. font-size: 32upx;
  1365. &.active{
  1366. color: #868686;
  1367. font-size: 24upx;
  1368. }
  1369. i{color: #62ed73;font-size: 48upx}
  1370. }
  1371. .member-wrap {
  1372. .member-det {
  1373. font-size: 24upx;
  1374. margin-left: 20upx;
  1375. }
  1376. }
  1377. .remark-wrap {
  1378. align-items: flex-start;
  1379. .remark {
  1380. height: 240upx;
  1381. }
  1382. }
  1383. }
  1384. }
  1385. .under-bar {
  1386. display: flex;
  1387. justify-content: space-between;
  1388. align-items: center;
  1389. padding: 0 20upx;
  1390. width: 100%;
  1391. height: 100upx;
  1392. background-color: #fff;
  1393. box-shadow: 0upx -1px 6upx 0upx rgba(4, 0, 0, 0.06);
  1394. /* #ifdef APP-PLUS */
  1395. position: fixed;
  1396. bottom: 0;
  1397. left: 0;
  1398. right: 0;
  1399. z-index: 999;
  1400. /* #endif */
  1401. /* #ifdef MP-WEIXIN */
  1402. position: fixed;
  1403. bottom: 0;
  1404. left: 0;
  1405. right: 0;
  1406. z-index: 999;
  1407. /* #endif */
  1408. .price-view {
  1409. display: flex;
  1410. align-items: center;
  1411. font-size: 24upx;
  1412. .price-title {
  1413. color: #333;
  1414. }
  1415. .price-number {
  1416. margin: 0 20upx;
  1417. color: #ff2842;
  1418. .large {
  1419. font-size: 40upx;
  1420. }
  1421. }
  1422. .price-discount-tip {
  1423. font-size: 28upx;
  1424. color: #ff7a00;
  1425. font-weight: bold;
  1426. white-space: nowrap;
  1427. }
  1428. }
  1429. .admin-button-com {
  1430. width: 200upx;
  1431. }
  1432. }
  1433. .coupon_box{
  1434. flex: 1;
  1435. text-align: right;
  1436. padding-right: 45upx;
  1437. .has-hb{
  1438. background:red;
  1439. color:white;
  1440. border:1upx solid red;
  1441. border-radius: 30upx;
  1442. font-size:20upx;
  1443. padding:5upx 15upx 5upx 15upx;
  1444. }
  1445. .selected{
  1446. color:red;
  1447. float:left;
  1448. }
  1449. }
  1450. .select-cmd_bx {
  1451. & .kc {
  1452. color: #999999;
  1453. font-size: 28upx;
  1454. font-weight: 400;
  1455. margin-bottom: 60upx;
  1456. text-align: center;
  1457. margin-top: 10upx;
  1458. }
  1459. & .num_bx {
  1460. display: flex;
  1461. align-items: center;
  1462. justify-content:center;
  1463. margin-bottom: 80upx;
  1464. & > input {
  1465. width: 280upx;
  1466. height: 80upx;
  1467. border: 1px solid #dddddd;
  1468. border-radius: 4upx;
  1469. text-align: center;
  1470. font-size: 40upx;
  1471. }
  1472. }
  1473. }
  1474. }
  1475. /* 跑腿平台报价样式 */
  1476. .delivery-quotes-container {
  1477. width: 100%;
  1478. margin-top: 20upx;
  1479. }
  1480. .delivery-quotes-grid {
  1481. display: flex;
  1482. flex-wrap: wrap;
  1483. gap: 10upx;
  1484. padding: 0;
  1485. width: 100%;
  1486. }
  1487. .delivery-quote-item {
  1488. display: flex;
  1489. flex-direction: column;
  1490. align-items: center;
  1491. justify-content: center;
  1492. flex: 0 0 calc(33% - 7upx);
  1493. width: calc(33% - 7upx);
  1494. min-height: 140upx;
  1495. padding: 16upx 10upx;
  1496. margin-bottom: 5upx;
  1497. background: #FFFFFF;
  1498. border: 2upx solid #DDDDDD;
  1499. border-radius: 8upx;
  1500. box-sizing: border-box;
  1501. transition: all 0.3s;
  1502. // 当只有1-2项时使用固定宽度
  1503. &.fixed-width {
  1504. flex: 0 0 220rpx;
  1505. width: 220rpx;
  1506. }
  1507. .platform-name {
  1508. font-size: 26upx;
  1509. color: #333;
  1510. font-weight: bold;
  1511. margin-bottom: 8upx;
  1512. text-align: center;
  1513. line-height: 1.3;
  1514. max-width: 100%;
  1515. overflow: hidden;
  1516. text-overflow: ellipsis;
  1517. display: -webkit-box;
  1518. -webkit-line-clamp: 2;
  1519. line-clamp: 2;
  1520. -webkit-box-orient: vertical;
  1521. word-break: break-all;
  1522. }
  1523. .platform-price {
  1524. font-size: 30upx;
  1525. color: #333;
  1526. font-weight: bold;
  1527. margin-bottom: 4upx;
  1528. }
  1529. .platform-type {
  1530. font-size: 20upx;
  1531. color: #868686;
  1532. margin-top: 4upx;
  1533. text-align: center;
  1534. line-height: 1.3;
  1535. max-width: 100%;
  1536. overflow: hidden;
  1537. text-overflow: ellipsis;
  1538. display: -webkit-box;
  1539. -webkit-line-clamp: 2;
  1540. line-clamp: 2;
  1541. -webkit-box-orient: vertical;
  1542. word-break: break-all;
  1543. }
  1544. // 选中状态
  1545. &.active {
  1546. background: #09C567;
  1547. border-color: #09C567;
  1548. .platform-name,
  1549. .platform-price {
  1550. color: #FFFFFF;
  1551. }
  1552. .platform-type {
  1553. color: rgba(255, 255, 255, 0.85);
  1554. }
  1555. }
  1556. // 不可用状态
  1557. &.disabled {
  1558. opacity: 0.5;
  1559. background: #F5F5F5;
  1560. .platform-name,
  1561. .platform-price,
  1562. .platform-type {
  1563. color: #CCCCCC;
  1564. }
  1565. }
  1566. }
  1567. /* 跑腿费价格样式 */
  1568. .delivery-price-normal {
  1569. color: #3385FF;
  1570. }
  1571. .delivery-price-free {
  1572. color: #999;
  1573. text-decoration: line-through;
  1574. }
  1575. .free-delivery-tag {
  1576. color: #3385FF;
  1577. margin-left: 20upx;
  1578. }
  1579. .delivery-policy-link {
  1580. color: rgb(201, 52, 52);
  1581. font-size: 28upx;
  1582. margin-left: 20upx;
  1583. font-weight: bold;
  1584. text-decoration: underline;
  1585. }
  1586. .policy-icon {
  1587. font-size: 28upx;
  1588. margin-left: 4upx;
  1589. }
  1590. .policy-popup-content {
  1591. width: 600upx;
  1592. background-color: #fff;
  1593. border-radius: 20upx;
  1594. padding: 30upx;
  1595. display: flex;
  1596. flex-direction: column;
  1597. align-items: center;
  1598. }
  1599. .policy-title {
  1600. font-size: 34upx;
  1601. font-weight: bold;
  1602. color: #333;
  1603. margin-bottom: 30upx;
  1604. }
  1605. .policy-scroll {
  1606. width: 100%;
  1607. max-height: 50vh;
  1608. margin-bottom: 30upx;
  1609. }
  1610. .policy-list {
  1611. width: 100%;
  1612. }
  1613. .policy-item {
  1614. font-size: 30upx;
  1615. color: #666;
  1616. margin-bottom: 20upx;
  1617. text-align: left;
  1618. line-height: 1.5;
  1619. display: list-item;
  1620. list-style-type: disc;
  1621. margin-left: 40upx;
  1622. }
  1623. .policy-btn {
  1624. width: 50%;
  1625. height: 80upx;
  1626. line-height: 80upx;
  1627. text-align: center;
  1628. background-color: #3385ff;
  1629. color: #fff;
  1630. font-size: 32upx;
  1631. border-radius: 40upx;
  1632. }
  1633. /* 配送业务面板样式 */
  1634. .wl-field-row {
  1635. display: flex;
  1636. flex-direction: row;
  1637. align-items: center;
  1638. flex: 1;
  1639. justify-content: flex-end;
  1640. min-width: 0;
  1641. }
  1642. .wl-name-input {
  1643. flex: 1;
  1644. min-width: 0;
  1645. text-align: left;
  1646. }
  1647. .wl-select-btn {
  1648. margin-left: 16upx;
  1649. flex-shrink: 0;
  1650. }
  1651. .wl-popup-content {
  1652. width: 680upx;
  1653. max-width: 90vw;
  1654. background: #fff;
  1655. border-radius: 20upx;
  1656. overflow: hidden;
  1657. }
  1658. .wl-popup-title {
  1659. padding: 30upx 30upx 10upx;
  1660. font-size: 30upx;
  1661. font-weight: bold;
  1662. color: #333;
  1663. }
  1664. .wl-popup-scroll {
  1665. max-height: 60vh;
  1666. }
  1667. .wl-popup-list {
  1668. display: flex;
  1669. flex-direction: row;
  1670. flex-wrap: wrap;
  1671. padding: 20upx 20upx 10upx;
  1672. }
  1673. .wl-popup-item {
  1674. margin-bottom: 20upx;
  1675. margin-right: 12upx;
  1676. }
  1677. .wl-option-btn {
  1678. min-width: 160upx;
  1679. padding: 0 27upx;
  1680. height: 80upx;
  1681. font-size: 32upx;
  1682. font-weight: bold;
  1683. border-radius: 16upx;
  1684. background: #f0f2f6;
  1685. color: #333;
  1686. border: 2upx solid #e0e0e0;
  1687. display: flex;
  1688. align-items: center;
  1689. justify-content: center;
  1690. }
  1691. .wl-option-btn.selected,
  1692. .wl-option-btn:active {
  1693. background: #3385ff;
  1694. color: #fff;
  1695. border-color: #3385ff;
  1696. }
  1697. .wl-popup-footer {
  1698. padding: 10upx 0 30upx;
  1699. text-align: center;
  1700. }
  1701. .wl-popup-cancel-btn {
  1702. width: 210upx;
  1703. }
  1704. .sh-method-btn {
  1705. width: 115upx;
  1706. height: 100upx;
  1707. margin-right: 15upx;
  1708. }
  1709. .sh-method-btn:last-child {
  1710. margin-right: 0;
  1711. }
  1712. .sh-method-btn--short {
  1713. line-height: 60upx;
  1714. }
  1715. .sh-method-btn--long {
  1716. line-height: 32upx;
  1717. }
  1718. .wl-popup-wrap {
  1719. z-index: 99999;
  1720. }
  1721. </style>