welcome-pack.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889
  1. <template>
  2. <div v-loading="loading">
  3. <div class="white-box" style="padding: 0 25px; margin-top: 25px;">
  4. <!-- <div class="noList">-->
  5. <!-- <el-select ref="select" @change="countriesChange" v-model="countries" filterable placeholder="">-->
  6. <!-- <el-option v-for="(item, index) in countriesList" :key="item.ID" :label="item.NAME" :value="item.ID" />-->
  7. <!-- </el-select>-->
  8. <!-- </div>-->
  9. <el-row :gutter="20">
  10. <el-col :xs="24" :sm="24" :lg="14">
  11. <el-form ref="form" label-width="180px" :label-position="labelPosition" class="form-page">
  12. <!-- <el-form-item :label="$t('user.welcomePackWay')">-->
  13. <!-- <el-radio-group v-model="form.decType" @change="decTypeChange">-->
  14. <!-- <el-radio size="small" label="normal">{{ $t('user.normal') }}</el-radio>-->
  15. <!-- &lt;!&ndash; <el-radio size="small" label="ba">{{ $t('user.BAUpgrade') }}</el-radio>&ndash;&gt;-->
  16. <!-- </el-radio-group>-->
  17. <!-- </el-form-item>-->
  18. <el-divider content-position="left">{{ $t('user.accountInformation') }}</el-divider>
  19. <el-form-item :label="$t('shop.country')">
  20. <el-select ref="select" @change="countriesChange" v-model="form.countryId" filterable :placeholder="$t('user.selectCountry')" style="width: 100%;">
  21. <el-option v-for="(item, index) in countriesList" :key="item.ID" :label="item.NAME" :value="item.ID" />
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item :label="$t('common.language')">
  25. <el-select ref="select" v-model="form.languageId" filterable :placeholder="$t('user.selectLanguage')" style="width: 100%;">
  26. <el-option v-for="(item, index) in languageList" :key="item.ID" :label="item.NAME" :value="item.ID" />
  27. </el-select>
  28. </el-form-item>
  29. <el-form-item :label="$t('user.newMemberCode')">
  30. <el-input v-model="form.insertUserName" :readonly="userReadOnly" @blur="checkBaUser" :placeholder="$t('user.enterMemberCode')" />
  31. </el-form-item>
  32. <el-form-item :label="$t('user.entryLevel')">
  33. <el-select v-model="form.decLv" :placeholder="$t('user.selectEntryLevel')" style="width: 100%;">
  34. <el-option v-for="item in allDecLevel" :key="item.ID" :label="item.LEVEL_NAME" :value="item.ID" />
  35. </el-select>
  36. </el-form-item>
  37. <el-form-item :label="$t('user.stockistCode')" :required="Number(isDec) === 0" >
  38. <el-input v-model="form.decUserName" :disabled="Number(isDec) === 1" />
  39. </el-form-item>
  40. <el-form-item>
  41. <template slot="label">
  42. {{ $t('user.selectWelcomePack') }}
  43. </template>
  44. <el-tabs v-model="decWay" type="border-card" style="position: relative; width: 100%;">
  45. <el-tab-pane :label="$t('shop.product')" name="2">
  46. <el-collapse v-model="activeName" accordion>
  47. <el-collapse-item name="product">
  48. <el-table :data="tableData" :show-header="false" @selection-change="handleSelectionChange">
  49. <el-table-column type="selection" width="30" align="center" style="top: -30px;" />
  50. <el-table-column align="center">
  51. <template slot-scope="{row, $index}">
  52. <el-container>
  53. <el-aside width="80px" style=" padding: 0; margin-bottom: 0; background-color: #ffffff;">
  54. <el-image style="width: 80px; height: 80px" :src="tool.getArImage(row.COVER, '/files/')" />
  55. </el-aside>
  56. <el-main style="padding: 0;">
  57. <div style="text-align: left; line-height: 25px;">
  58. <span style="font-weight: bold; cursor: pointer;" @click="handleProduct(row)">{{ row.GOODS_NAME }}</span><br>
  59. <span>{{ row.GOODS_NO }}</span><br>
  60. <span style="color: tomato;">{{ $t('shop.salesPrice') }}:{{row.CODE}} {{ row.SELL_PRICE | toThousandFilter }}</span><br>
  61. <span>{{ $t('shop.productBV') }}:{{ row.PRICE_PV | toThousandFilter }}</span><br>
  62. <span>{{ $t('shop.marketPrice') }}:{{row.CODE}} {{ row.MARKET_PRICE | toThousandFilter }}</span><br>
  63. <span style="display: inline-block; float: right; ">
  64. <el-input-number v-model="storeNums[$index]" size="mini" :min="1" :max="Number(row.STORE_NUMS)" @change="handleInputNumber($event, row)" />
  65. </span>
  66. <br>
  67. </div>
  68. </el-main>
  69. </el-container>
  70. </template>
  71. </el-table-column>
  72. </el-table>
  73. </el-collapse-item>
  74. </el-collapse>
  75. <div class="white-box-footer">
  76. <div class="flex data" style="float: right; display: inline-block; line-height: 30px; font-size: 14px; margin-top: 15px; margin-bottom: 10px; border: 1px solid #dcdfe6; border-radius: 4px; padding: 0 5px;">
  77. <div style="margin-right: 1rem; display: inline-block;">{{ $t('shop.productPrice') }}: {{currencyUnitCode}} {{ sellPriceSum | toThousandFilter }}</div>
  78. <div style="margin-right: 1rem; display: inline-block;">{{ $t('shop.productBV') }}:{{ pricePvSum | toThousandFilter }}</div>
  79. <div style="display: inline-block;">{{ $t('shop.taxAmount') }}:{{currencyUnitCode}} {{ taxSum }}</div>
  80. </div>
  81. </div>
  82. </el-tab-pane>
  83. </el-tabs>
  84. </el-form-item>
  85. <el-divider content-position="left">{{ $t('atlas.networkInformation') }}</el-divider>
  86. <el-form-item :label="$t('user.recommenderName')">
  87. <el-input v-model="form.recUserName" :readonly="recReadOnly" @change="handleChkRecUser" />
  88. </el-form-item>
  89. <el-form-item>
  90. <el-input v-model="recRealName" :disabled="true" />
  91. </el-form-item>
  92. <el-form-item :label="$t('user.recommenderActualName')">
  93. <el-input v-model="form.conUserName" @change="handleChkRecommenderActualName" />
  94. </el-form-item>
  95. <el-form-item>
  96. <el-input v-model="conRealName" type="textarea" :rows="2" :disabled="true" />
  97. </el-form-item>
  98. <!-- <el-form-item :label="$t('atlas.placementTree')">-->
  99. <!-- <el-radio-group v-model="form.location" border>-->
  100. <!-- <el-radio :label="1">{{ $t('atlas.left') }}</el-radio>-->
  101. <!-- <el-radio :label="2">{{ $t('atlas.right') }}</el-radio>-->
  102. <!-- </el-radio-group>-->
  103. <!-- </el-form-item>-->
  104. <!-- <el-form-item>&lt;!&ndash;自动安置区位&ndash;&gt;-->
  105. <!-- <el-row :gutter="5">-->
  106. <!-- <el-col :xs="24" :sm="12" :lg="12">-->
  107. <!-- <el-button size="small" type="primary" @click="setAutoPlace('left')">{{ $t('atlas.placementAutoLeft') }}</el-button>-->
  108. <!-- </el-col>-->
  109. <!-- <el-col :xs="24" :sm="12" :lg="12">-->
  110. <!-- <el-button size="small" type="primary" @click="setAutoPlace('right')">{{ $t('atlas.placementAutoRight') }}</el-button>-->
  111. <!-- </el-col>-->
  112. <!-- </el-row>-->
  113. <!-- </el-form-item>-->
  114. <el-divider content-position="left">{{ $t('profile.personalInformation') }}</el-divider>
  115. <el-form-item :label="$t('shop.memberName')">
  116. <el-input v-model="form.realName" />
  117. </el-form-item>
  118. <el-form-item :label="$t('shop.phoneNumber')">
  119. <el-input v-model="form.mobile" />
  120. </el-form-item>
  121. <el-form-item :label="$t('user.email')">
  122. <el-input v-model="form.email" />
  123. </el-form-item>
  124. <el-form-item :label="$t('profile.loginPassword')">
  125. <el-input v-model="form.password" maxlength="32" :placeholder="$t('profile.enterLoginPassword')" />
  126. </el-form-item>
  127. <el-form-item :label="$t('profile.paymentPassword')">
  128. <el-input v-model="form.payPassword" maxlength="32" :placeholder="$t('profile.enterPaymentPassword')" />
  129. </el-form-item>
  130. <el-form-item :label="$t('shop.recipientName')">
  131. <el-input v-model="form.consignee" />
  132. </el-form-item>
  133. <el-form-item :label="$t('shop.phoneNumber')">
  134. <el-input v-model="form.acceptMobile" />
  135. </el-form-item>
  136. <el-form-item :label="$t('shop.shipping')">
  137. <el-radio-group v-model="form.way" @change="wayChange">
  138. <el-radio label="express">{{ $t('shop.delivery') }}</el-radio>
  139. <el-radio label="pickup">{{ $t('shop.selfPickUp') }}</el-radio>
  140. </el-radio-group>
  141. </el-form-item>
  142. <el-form-item prop="areaSelected" :label="$t('config.state')">
  143. <el-cascader v-model="form.areaSelected" :disabled="areaDisabled" size="large" :placeholder="$t('shop.delivery')" :options="regionData" style="width: 100%;" />
  144. </el-form-item>
  145. <el-form-item :label="$t('config.detailedAddress')">
  146. <el-input v-model="form.address" :disabled="addressDisabled" />
  147. </el-form-item>
  148. <el-form-item :label="$t('config.city')">
  149. <el-input v-model="form.cityName" :disabled="addressDisabled" />
  150. </el-form-item>
  151. <el-form-item :label="$t('config.localGovernmentArea')">
  152. <el-input v-model="form.lgaName" :disabled="addressDisabled" />
  153. </el-form-item>
  154. <el-divider content-position="left">{{ $t('finance.bankInformation') }}</el-divider>
  155. <el-form-item :label="$t('finance.bankName')">
  156. <el-select v-model="form.openBank" :placeholder="$t('finance.selectBank')" style="width: 100%;">
  157. <el-option v-for="(item,index) in allOpenBank" :key="index" :label="item.BANK_NAME" :value="item.BANK_CODE" />
  158. </el-select>
  159. </el-form-item>
  160. <el-form-item :label="$t('finance.accountName')">
  161. <el-input v-model="form.bankAddress" />
  162. </el-form-item>
  163. <el-form-item :label="$t('finance.bankAccount')">
  164. <el-input v-model="form.bankNo" maxlength="50" />
  165. </el-form-item>
  166. <el-divider content-position="left">{{ $t('user.payInfo') }}</el-divider>
  167. <el-form-item :label="$t('shop.paymentMethod')" required>
  168. <el-radio-group v-model="form.payType" @change="chosePayType">
  169. <el-radio v-for="(item, index) in payList" :key="index" border :label="item.label" style="margin: 5px;">
  170. {{ item.name }}<span v-if="item.label === 'cash'" style="color: tomato;">( {{currencyUnitCode}} {{ userBalance.localCash }})</span>
  171. </el-radio>
  172. </el-radio-group>
  173. </el-form-item>
  174. <el-form-item>
  175. <el-button size="small" type="primary" :loading="submitButtonStat" @click="onSubmit">{{ $t('common.save') }}</el-button>
  176. </el-form-item>
  177. </el-form>
  178. </el-col>
  179. </el-row>
  180. </div>
  181. <!-- payStack模态框 -->
  182. <el-dialog v-loading="payStackLoading" :title="$t('shop.goPay')" :visible.sync="visible" :width="payStackScreenWidth" :before-close="handleClose">
  183. <section>
  184. <el-form :model="payForm">
  185. <el-form-item :label="$t('user.email')" label-width="100px" required>
  186. <el-input v-model="payForm.email" autocomplete="off" />
  187. </el-form-item>
  188. <el-form-item :label="$t('shop.amount')" label-width="100px" required>
  189. <el-input v-model="payForm.amount" autocomplete="off" readonly />
  190. </el-form-item>
  191. </el-form>
  192. </section>
  193. <paystack
  194. :firstname="payForm.firstname"
  195. :lastname="payForm.lastname"
  196. :amount="payForm.amount * 100"
  197. :email="payForm.email"
  198. :metadata="payForm.metadata"
  199. :currency="payForm.currency"
  200. :paystackkey="payForm.publicKey"
  201. :reference="reference"
  202. :channels="channels"
  203. :callback="processPayment"
  204. :close="handleClose"
  205. >
  206. <el-button type="primary" size="small">{{ $t('shop.goPay') }}</el-button>
  207. </paystack>
  208. <el-button type="danger" size="small" class="cancelButton" style="margin-left: 10px;" @click="handleClose">{{ $t('common.cancel') }}</el-button>
  209. </el-dialog>
  210. <!-- 倒计时页面 -->
  211. <el-dialog :title="$t('common.hint')" :visible.sync="payDialog" :width="payStackScreenWidth" :show-close="false" :close="handleOrderList">
  212. <el-card shadow="always">
  213. <el-result icon="success" :title="$t('common.successfully')" :sub-title="$t('shop.successOrderTips')">
  214. <template slot="extra">
  215. <el-button type="primary" size="medium" @click="handleOrderList">{{ $t('shop.goBack') }}({{ countdown }})</el-button>
  216. </template>
  217. </el-result>
  218. </el-card>
  219. </el-dialog>
  220. <!-- 商品详情 -->
  221. <el-dialog :title="product.GOODS_NO" :visible.sync="visibleProduct" :width="screenWidth" style="margin-top: -95px;">
  222. <el-row :gutter="20">
  223. <el-col :xs="24" :sm="12" :lg="12">
  224. <el-image style="width: 100%; height: 100%" :style="imageStyle" :src="tool.getArImage(product.COVER, '/files/')" />
  225. </el-col>
  226. <el-col :xs="24" :sm="12" :lg="12">
  227. <div style="text-align: left; line-height: 50px; font-size: 16px;">
  228. <span style="font-weight: bold; font-size: 20px;">{{ product.GOODS_NAME }}</span><br>
  229. <span style="font-weight: bold; font-size: 15px;">{{ $t('shop.productCode') }}:{{ product.GOODS_NO }}</span><br>
  230. <span style="color: tomato;">{{ $t('shop.salesPrice') }}:{{currencyUnitCode}} {{ product.SELL_PRICE }}</span><br>
  231. <span>{{ $t('shop.marketPrice') }}:{{currencyUnitCode}} {{ product.MARKET_PRICE }}</span><br>
  232. <span>{{ $t('shop.productBV') }}:{{ product.PRICE_PV }}</span><br>
  233. <span>{{ $t('shop.taxRate') }}:{{ product.TAX_RATE / 100 }}</span><br>
  234. <span>{{ $t('shop.taxAmount') }}:{{currencyUnitCode}} {{ product.taxAmount }}</span><br>
  235. <span>{{ $t('shop.inventory') }}:{{ product.STORE_NUMS }}</span>
  236. </div>
  237. </el-col>
  238. </el-row>
  239. </el-dialog>
  240. </div>
  241. </template>
  242. <script>
  243. import { deleteApproachOrder } from '@/api/shop'
  244. import {
  245. createWelcomePack,
  246. fetchAutoPlace,
  247. fetchBrandAmbassadorInfo,
  248. fetchFullInfo,
  249. fetchInspectNetwork,
  250. fetchWelcomePack
  251. } from '@/api/user'
  252. import Pagination from '@/components/Pagination'
  253. import waves from '@/directive/waves'
  254. import region from '@/store/modules/region'
  255. import { getScreenWidth } from '@/utils'
  256. import tool from '@/utils/tool'
  257. import usersInfo from '@/utils/usersInfo'
  258. import paystack from 'vue-paystack'
  259. export default {
  260. name: 'WelcomePack',
  261. components: { Pagination, paystack },
  262. directives: { waves },
  263. filters: {
  264. bvFilter(row) {
  265. return tool.calculateBV(row.REAL_PV, row.BUY_NUMS)
  266. },
  267. taxAmountFilter(row) {
  268. return tool.calculateTax(row.REAL_PRICE, row.BUY_NUMS)
  269. },
  270. priceAmountFilter(row) {
  271. return tool.formatPrice(row.REAL_PRICE * row.BUY_NUMS)
  272. },
  273. statusFilter(status) {
  274. const statusMap = {
  275. Unpaid: 'info',
  276. Paid: 'success'
  277. }
  278. return statusMap[status]
  279. }
  280. },
  281. data() {
  282. return {
  283. isChooseCountry: false,
  284. loading: false,
  285. tool: tool,
  286. allGoods: [],
  287. numList: [],
  288. categoryType: '',
  289. sellType: [],
  290. payList: [],
  291. screenWidth: getScreenWidth() > 600 ? '50%' : getScreenWidth() + 'px',
  292. labelPosition: getScreenWidth() > 600 ? 'right' : 'top',
  293. payStackScreenWidth: getScreenWidth() > 500 ? '450px' : getScreenWidth() + 'px',
  294. dialog: false,
  295. dialogLoading: false,
  296. multipleSelection: [],
  297. sellPriceSum: 0.00,
  298. pricePvSum: 0.00,
  299. taxSum: 0.00,
  300. storeNums: [],
  301. tableData: null,
  302. payAmount: 0.00,
  303. cashCurrency: '',
  304. currency: {},
  305. pointsSum: 0,
  306. cashSum: 0,
  307. pointFreight: 0,
  308. freeShipping: '',
  309. goodsId: '',
  310. goodsNum: '',
  311. payPassword: '',
  312. submitButtonStat: false,
  313. sn: '',
  314. orderType: '',
  315. payDialog: false,
  316. countdown: 5,
  317. visible: false,
  318. totalAmount: 0.00,
  319. freight: 0.00,
  320. userBalance: {
  321. cash: 0,
  322. localCash: 0,
  323. },
  324. payType: 'cash',
  325. payStackLoading: false,
  326. channels: ['card', 'bank', 'ussd', 'qr'],
  327. payForm: {
  328. publicKey: process.env.VUE_APP_BASE_PAY_STACK_PUBLIC_KEY,
  329. currency: 'NGN',
  330. firstname: usersInfo.userName(),
  331. lastname: '',
  332. email: usersInfo.userEmail(),
  333. amount: 0,
  334. orderSn: '',
  335. metadata: {
  336. cart_id: '',
  337. custom_fields: [
  338. {
  339. display_name: 'orderSn',
  340. variable_name: 'orderSn',
  341. value: this.sn
  342. },
  343. {
  344. display_name: 'orderType',
  345. variable_name: 'orderType',
  346. value: 'baDec'
  347. }
  348. ]
  349. }
  350. },
  351. addressId: '',
  352. selfPickUpAddressId: '100000000000000000',
  353. shippingAddressList: [],
  354. visibleProduct: false,
  355. product: {
  356. GOODS_NAME: '',
  357. GOODS_NO: '',
  358. COVER: '',
  359. SELL_PRICE: 0,
  360. PRICE_PV: 0,
  361. TAX_RATE: 0,
  362. taxAmount: 0
  363. },
  364. imageStyle: 'margin-top: 0px;',
  365. decWay: '2',
  366. regionData: [],
  367. form: {
  368. decType: 'normal',
  369. realName: '',
  370. decLv: '',
  371. insertUserName: '',
  372. decUserName: '',
  373. recUserName: '',
  374. conUserName: '',
  375. insertUserIdCard: '',
  376. consignee: '',
  377. acceptMobile: '',
  378. areaSelected: [],
  379. address: '',
  380. openBank: '',
  381. bankAddress: '',
  382. bankProvince: '',
  383. bankCity: '',
  384. bankCounty: '',
  385. bankNo: '',
  386. bankAreaSelected: [],
  387. password: '111111',
  388. payPassword: '111111',
  389. mobile: '',
  390. email: '',
  391. packageId: '',
  392. goodsId: [],
  393. goodsNum: [],
  394. province: '',
  395. cityName: '',
  396. lgaName: '',
  397. way: 'express',
  398. payType: '',
  399. autoPlace: '',
  400. location: ''
  401. },
  402. conRealName: '-',
  403. recRealName: '-',
  404. areaDisabled: false,
  405. addressDisabled: false,
  406. userReadOnly: true,
  407. recReadOnly: false,
  408. allDecLevel: [],
  409. allOpenBank: [],
  410. activeName: 'product',
  411. isDec:null,
  412. countries: null,
  413. currencyUnitCode: ""
  414. }
  415. },
  416. computed: {
  417. // PayStack混淆串
  418. reference() {
  419. let text = ''
  420. const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
  421. for (let i = 0; i < 10; i++) {
  422. text += possible.charAt(Math.floor(Math.random() * possible.length))
  423. }
  424. return text
  425. },
  426. countriesList() {
  427. return this.$store.getters.getCountriesList
  428. },
  429. languageList() {
  430. return this.$store.getters.languageList
  431. },
  432. language() {
  433. return this.$store.getters.language
  434. },
  435. },
  436. watch: {
  437. isDec: {
  438. handler(newValue, old) {
  439. if (newValue == '1') {
  440. this.form.decUserName = usersInfo.userName();
  441. }
  442. },
  443. }
  444. },
  445. created() {
  446. const regionInfo = this.$store.getters.regionInfo
  447. // console.log(this.$store.state.region)
  448. // this.fetchWelcomePack()
  449. this.getCountries()
  450. },
  451. methods: {
  452. countriesChange(e){
  453. this.fetchWelcomePack()
  454. },
  455. //国家列表
  456. getCountries() {
  457. this.$store.dispatch('settings/getCountries')
  458. },
  459. // 会员报单/BA升级
  460. fetchWelcomePack() {
  461. this.loading = true
  462. fetchWelcomePack({countryId: this.form.countryId}).then(response => {
  463. this.form.insertUserName = response.data.userName
  464. this.allOpenBank = response.data.allOpenBank
  465. this.allDecPackage = response.data.allDecPackage
  466. this.allGoods = response.data.allGoods
  467. this.userBalance = response.data.userBalance
  468. this.regionData = response.data.region
  469. this.allDecLevel = response.data.decLevel
  470. this.categoryType = 1
  471. if(response.data.allGoods && response.data.allGoods.length > 0){
  472. this.currencyUnitCode = response.data.allGoods[0].CODE
  473. }
  474. //是否是报单中心
  475. this.isDec = response.data.isDec
  476. const settingObj = this.allGoods
  477. for (const i in this.allGoods) {
  478. this.storeNums[i] = 1
  479. settingObj[i].goodsNum = 0
  480. }
  481. this.tableData = Object.values(settingObj)
  482. const pageList = this.multipleSelection
  483. this.$nextTick(function() {
  484. for (const i in this.tableData) {
  485. for (const j in pageList) {
  486. if (pageList[j].ID === this.tableData[i].ID) {
  487. this.$data.storeNums[i] = pageList[j].goodsNum
  488. this.tableData[i].goodsNum = pageList[j].goodsNum
  489. break
  490. }
  491. }
  492. }
  493. })
  494. // 支付方式
  495. this.payList = response.data.sellType[0]['sell_type']
  496. // 支付方式的第一项默认选中
  497. this.form.payType = Object.values(this.payList)[1]['label']
  498. setTimeout(() => {
  499. this.loading = false
  500. }, 0.5 * 1000)
  501. }).catch(err => {
  502. console.log(err)
  503. this.loading = false
  504. })
  505. },
  506. // 商品详情
  507. handleProduct(row) {
  508. this.product = row
  509. this.product.taxAmount = tool.calculateTax(row.MARKET_PRICE, row.TAX_RATE)
  510. this.visibleProduct = true
  511. },
  512. // 选择商品计数
  513. handleInputNumber(current, row) {
  514. const pageList = this.multipleSelection
  515. let selectStatus = false
  516. for (const i in pageList) {
  517. if (pageList[i].ID === row.ID) {
  518. pageList[i].goodsNum = current
  519. selectStatus = true
  520. break
  521. }
  522. }
  523. if (selectStatus) {
  524. this.multipleSelection = pageList
  525. this.handleSureChange()
  526. }
  527. },
  528. // 统计商品
  529. handleSureChange() {
  530. if (this.multipleSelection.length > 0) {
  531. let accumulatorSellPrice = 0; let accumulatorPricePv = 0; let accumulatorTax = 0
  532. this.multipleSelection.forEach(accumulator => {
  533. accumulatorSellPrice += accumulator.MARKET_PRICE * accumulator.goodsNum
  534. accumulatorPricePv += Number(accumulator.PRICE_PV) * Number(accumulator.goodsNum)
  535. accumulatorTax += tool.calculateTax(Number(accumulator.MARKET_PRICE), Number(accumulator.TAX_RATE), Number(accumulator.goodsNum))
  536. })
  537. this.sellPriceSum = tool.formatPrice(accumulatorSellPrice)
  538. this.pricePvSum = tool.formatPrice(accumulatorPricePv)
  539. this.taxSum = tool.formatPrice(accumulatorTax)
  540. this.display = true
  541. } else {
  542. this.sellPriceSum = this.pricePvSum = this.taxSum = 0.00
  543. this.display = true
  544. }
  545. },
  546. // 选择商品
  547. handleSelectionChange(val) {
  548. let idx = -1; let num
  549. for (const i in this.tableData) {
  550. for (const v in val) {
  551. if (val[v].ID === this.tableData[i].ID) {
  552. idx = i
  553. num = this.storeNums[idx]
  554. val[v]['goodsNum'] = num
  555. break
  556. }
  557. }
  558. }
  559. this.multipleSelection = val
  560. // 计算统计
  561. this.handleSureChange()
  562. },
  563. // 选择收货地址
  564. choseAddress(addressId) {
  565. this.addressId = addressId
  566. // 设置运费
  567. this.setFreight()
  568. // 计算价格
  569. this.getSumMoney()
  570. },
  571. // 切换支付方式
  572. chosePayType(type) {
  573. this.payType = type
  574. },
  575. // 关闭支付回调
  576. handleClose() {
  577. this.$confirm(this.$t('shop.confirmClose')).then(_ => {
  578. deleteApproachOrder({ orderSn: this.form.orderSn }).then(() => {
  579. // 关闭支付模态框
  580. this.visible = false
  581. // 关闭购物车
  582. this.visibleShoppingCart = false
  583. this.submitButtonStat = false
  584. })
  585. })
  586. },
  587. // 支付成功回调
  588. processPayment() {
  589. // 关闭支付页面
  590. this.visible = false
  591. this.payStackLoading = false
  592. // 显示支付成功模态框
  593. this.payDialog = true
  594. // 启动支付成功倒计时
  595. this.handleCountdown()
  596. },
  597. // 倒计时结束跳转
  598. handleOrderList() {
  599. this.$router.push({ path: `/shop/member-order` })
  600. },
  601. // 启动倒计时
  602. handleCountdown() {
  603. // 创建定时器
  604. setInterval(() => {
  605. // 每隔1秒把time的值减一,赋值给span标签
  606. this.countdown--
  607. if (this.countdown === 0) {
  608. // 倒计时结束,跳转到订单列表
  609. this.$router.push({ path: `/shop/member-order` })
  610. }
  611. }, 1000)
  612. },
  613. // 会员查询
  614. handleChkRecUser() {
  615. this.form.conUserName = ''
  616. this.conRealName = '-'
  617. this.form.autoPlace = ''
  618. if (this.form.recUserName) {
  619. this.loading = true
  620. fetchFullInfo({ userName: this.form.recUserName }).then(response => {
  621. this.recRealName = response.data.REAL_NAME
  622. this.loading = false
  623. }).catch(() => {
  624. this.recRealName = '-'
  625. this.loading = false
  626. })
  627. }
  628. },
  629. // 返回方式
  630. wayChange() {
  631. if (this.form.way === 'pickup') {
  632. this.areaDisabled = true
  633. this.addressDisabled = true
  634. } else {
  635. this.areaDisabled = false
  636. this.addressDisabled = false
  637. }
  638. },
  639. // 会员报单/BA升级
  640. onSubmit() {
  641. if (!this.form.decLv) {
  642. this.$message({
  643. message: this.$t('profile.selectLevel'),
  644. type: 'error'
  645. })
  646. return false
  647. }
  648. if (this.isDec == 0 && !this.form.decUserName) {
  649. this.$message({
  650. message: this.$t('shop.declarationCenterNumberTips'),
  651. type: 'error'
  652. })
  653. return false
  654. }
  655. // 已选择商品
  656. this.selectProduct()
  657. if (this.multipleSelection.length <= 0) {
  658. this.$message.error(this.$t('shop.chooseTips'))
  659. return false
  660. }
  661. // 余额
  662. const amountBalance = this.userBalance[this.form.payType] || 0
  663. // 余额是否充足
  664. if ((this.form.payType === 'cash') && ((amountBalance - this.payAmount) < 0)) {
  665. // 账户类型提示信息
  666. const payListArray = Array.from(this.form.payType)
  667. const account = payListArray.filter(item => {
  668. return this.form.payType === item.label
  669. })
  670. const accountType = account[0] && account[0].name || ''
  671. this.$message({
  672. message: accountType + this.$t('shop.balanceNotAllow'),
  673. type: 'error'
  674. })
  675. return false
  676. }
  677. this.submitButtonStat = true
  678. const params = {
  679. consignee: this.form.consignee,
  680. acceptMobile: this.form.acceptMobile,
  681. province: this.form.areaSelected[0] ? this.form.areaSelected[0] : '',
  682. city: this.form.areaSelected[1] ? this.form.areaSelected[1] : '',
  683. county: this.form.areaSelected[2] ? this.form.areaSelected[2] : '',
  684. address: this.form.address,
  685. decType: this.form.decType,
  686. insertUserName: this.form.insertUserName,
  687. decLv: this.form.decLv,
  688. realName: this.form.realName,
  689. decUserName: this.form.decUserName,
  690. conUserName: this.form.conUserName,
  691. recUserName: this.form.recUserName,
  692. insertUserIdCard: this.form.insertUserIdCard,
  693. openBank: this.form.openBank,
  694. bankAddress: this.form.bankAddress,
  695. mobile: this.form.mobile,
  696. email: this.form.email,
  697. cityName: this.form.cityName,
  698. lgaName: this.form.lgaName,
  699. bankProvince: this.form.bankAreaSelected[0] ? this.form.bankAreaSelected[0] : '',
  700. bankCity: this.form.bankAreaSelected[1] ? this.form.bankAreaSelected[1] : '',
  701. bankCounty: this.form.bankAreaSelected[2] ? this.form.bankAreaSelected[2] : '',
  702. bankNo: this.form.bankNo,
  703. password: this.form.password,
  704. payPassword: this.form.payPassword,
  705. packageId: this.form.packageId,
  706. goodsId: this.form.goodsId,
  707. goodsNum: this.form.goodsNum,
  708. location: 1, //自动安置
  709. decWay: this.decWay,
  710. payType: this.form.payType,
  711. countryId: this.form.countryId,
  712. languageId: this.form.languageId
  713. }
  714. createWelcomePack(params).then(response => {
  715. if (this.form.payType !== 'pay_stack') {
  716. // 余额支付
  717. this.$message({
  718. message: this.$t('common.successfully'),
  719. type: 'success'
  720. })
  721. this.submitButtonStat = false
  722. this.$router.push({ path: `/shop/member-order` })
  723. } else {
  724. this.submitButtonStat = false
  725. this.payForm.orderSn = response.data.SN
  726. this.payForm.amount = response.data.ORDER_AMOUNT
  727. this.payForm.metadata.custom_fields[0].value = response.data.SN
  728. if (this.form.decType === 'ba') {
  729. this.payForm.metadata.custom_fields[1].value = 'baUpgrade'
  730. } else {
  731. this.payForm.metadata.custom_fields[1].value = 'userDec'
  732. }
  733. this.visible = true
  734. }
  735. }).catch(err => {
  736. this.$message({
  737. message: err,
  738. type: 'error'
  739. })
  740. this.submitButtonStat = false
  741. })
  742. },
  743. // 已选择商品
  744. selectProduct() {
  745. this.payAmount = 0
  746. this.form.goodsId = []
  747. this.form.goodsNum = []
  748. this.multipleSelection.map((item) => {
  749. this.form.goodsId.push(item.ID)
  750. this.form.goodsNum.push(item.goodsNum)
  751. this.payAmount += item.goodsNum * item.MARKET_PRICE
  752. })
  753. },
  754. // 报单方式
  755. decTypeChange() {
  756. if (this.form.decType === 'ba') {
  757. this.form.insertUserName = ''
  758. this.userReadOnly = false
  759. } else {
  760. this.form.recUserName = ''
  761. this.recRealName = '-'
  762. this.recReadOnly = false
  763. this.userReadOnly = true
  764. this.fetchWelcomePack()
  765. }
  766. },
  767. // BA会员查询
  768. checkBaUser() {
  769. if (this.form.decType === 'ba' && this.form.insertUserName !== '') {
  770. this.loading = true
  771. fetchBrandAmbassadorInfo({ userName: this.form.insertUserName }).then(response => {
  772. this.form.recUserName = response.data.REC_USER_NAME
  773. this.form.realName = response.data.REAL_NAME
  774. this.handleChkRecUser()
  775. this.recReadOnly = true
  776. this.loading = false
  777. }).catch(() => {
  778. this.loading = false
  779. })
  780. }
  781. },
  782. // 查询安置人
  783. handleChkConUser() {
  784. if (this.form.conUserName) {
  785. this.loading = true
  786. fetchFullInfo({ userName: this.form.conUserName }).then(response => {
  787. this.conRealName = response.data.REAL_NAME + response.data.isLocation
  788. this.loading = false
  789. }).catch(() => {
  790. this.conRealName = '-'
  791. this.loading = false
  792. })
  793. }
  794. },
  795. // 查询安置人
  796. handleChkRecommenderActualName() {
  797. if (this.form.conUserName) {
  798. this.loading = true
  799. fetchInspectNetwork({ recommenderName: this.form.recUserName, recommenderActualName: this.form.conUserName }).then(response => {
  800. this.conRealName = response.data.REAL_NAME
  801. this.loading = false
  802. }).catch(() => {
  803. this.conRealName = '-'
  804. this.loading = false
  805. })
  806. }
  807. },
  808. // 自动设置区位
  809. setAutoPlace(side) {
  810. if (this.recRealName !== '-') {
  811. this.loading = true
  812. fetchAutoPlace({ userName: this.form.recUserName, side: side }).then(response => {
  813. this.form.conUserName = response.data.USER_NAME
  814. this.handleChkConUser()
  815. this.form.location = 1
  816. this.form.autoPlace = side
  817. this.loading = false
  818. }).catch(() => {
  819. this.conRealName = '-'
  820. this.loading = false
  821. })
  822. } else {
  823. this.form.autoPlace = ''
  824. return false
  825. }
  826. }
  827. }
  828. }
  829. </script>
  830. <style>
  831. .el-table th.el-table__cell > .cell {
  832. white-space: nowrap;
  833. }
  834. .el-table td.el-table__cell > .cell {
  835. word-break: keep-all;
  836. white-space: pre-wrap;
  837. }
  838. .el-tabs--border-card > .el-tabs__content {
  839. padding: 5px;
  840. }
  841. .el-radio.is-bordered + .el-radio.is-bordered {
  842. margin: 5px 0;
  843. }
  844. .el-radio--medium.is-bordered {
  845. margin: 5px 0;
  846. }
  847. .noList{
  848. margin: 10px 0;
  849. }
  850. </style>