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.cash }})</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. },
  323. payType: 'cash',
  324. payStackLoading: false,
  325. channels: ['card', 'bank', 'ussd', 'qr'],
  326. payForm: {
  327. publicKey: process.env.VUE_APP_BASE_PAY_STACK_PUBLIC_KEY,
  328. currency: 'NGN',
  329. firstname: usersInfo.userName(),
  330. lastname: '',
  331. email: usersInfo.userEmail(),
  332. amount: 0,
  333. orderSn: '',
  334. metadata: {
  335. cart_id: '',
  336. custom_fields: [
  337. {
  338. display_name: 'orderSn',
  339. variable_name: 'orderSn',
  340. value: this.sn
  341. },
  342. {
  343. display_name: 'orderType',
  344. variable_name: 'orderType',
  345. value: 'baDec'
  346. }
  347. ]
  348. }
  349. },
  350. addressId: '',
  351. selfPickUpAddressId: '100000000000000000',
  352. shippingAddressList: [],
  353. visibleProduct: false,
  354. product: {
  355. GOODS_NAME: '',
  356. GOODS_NO: '',
  357. COVER: '',
  358. SELL_PRICE: 0,
  359. PRICE_PV: 0,
  360. TAX_RATE: 0,
  361. taxAmount: 0
  362. },
  363. imageStyle: 'margin-top: 0px;',
  364. decWay: '2',
  365. regionData: [],
  366. form: {
  367. decType: 'normal',
  368. realName: '',
  369. decLv: '',
  370. insertUserName: '',
  371. decUserName: '',
  372. recUserName: '',
  373. conUserName: '',
  374. insertUserIdCard: '',
  375. consignee: '',
  376. acceptMobile: '',
  377. areaSelected: [],
  378. address: '',
  379. openBank: '',
  380. bankAddress: '',
  381. bankProvince: '',
  382. bankCity: '',
  383. bankCounty: '',
  384. bankNo: '',
  385. bankAreaSelected: [],
  386. password: '111111',
  387. payPassword: '111111',
  388. mobile: '',
  389. email: '',
  390. packageId: '',
  391. goodsId: [],
  392. goodsNum: [],
  393. province: '',
  394. cityName: '',
  395. lgaName: '',
  396. way: 'express',
  397. payType: '',
  398. autoPlace: '',
  399. location: ''
  400. },
  401. conRealName: '-',
  402. recRealName: '-',
  403. areaDisabled: false,
  404. addressDisabled: false,
  405. userReadOnly: true,
  406. recReadOnly: false,
  407. allDecLevel: [],
  408. allOpenBank: [],
  409. activeName: 'product',
  410. isDec:null,
  411. countries: null,
  412. currencyUnitCode: ""
  413. }
  414. },
  415. computed: {
  416. // PayStack混淆串
  417. reference() {
  418. let text = ''
  419. const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
  420. for (let i = 0; i < 10; i++) {
  421. text += possible.charAt(Math.floor(Math.random() * possible.length))
  422. }
  423. return text
  424. },
  425. countriesList() {
  426. return this.$store.getters.getCountriesList
  427. },
  428. languageList() {
  429. return this.$store.getters.languageList
  430. },
  431. language() {
  432. return this.$store.getters.language
  433. },
  434. },
  435. watch: {
  436. isDec: {
  437. handler(newValue, old) {
  438. if (newValue == '1') {
  439. this.form.decUserName = usersInfo.userName();
  440. }
  441. },
  442. }
  443. },
  444. created() {
  445. const regionInfo = this.$store.getters.regionInfo
  446. // console.log(this.$store.state.region)
  447. // this.fetchWelcomePack()
  448. this.getCountries()
  449. },
  450. methods: {
  451. countriesChange(e){
  452. this.fetchWelcomePack()
  453. },
  454. //国家列表
  455. getCountries() {
  456. this.$store.dispatch('settings/getCountries')
  457. },
  458. // 会员报单/BA升级
  459. fetchWelcomePack() {
  460. this.loading = true
  461. fetchWelcomePack({countryId: this.form.countryId}).then(response => {
  462. this.form.insertUserName = response.data.userName
  463. this.allOpenBank = response.data.allOpenBank
  464. this.allDecPackage = response.data.allDecPackage
  465. this.allGoods = response.data.allGoods
  466. this.userBalance = response.data.userBalance
  467. this.regionData = response.data.region
  468. this.allDecLevel = response.data.decLevel
  469. this.categoryType = 1
  470. if(response.data.allGoods && response.data.allGoods.length > 0){
  471. this.currencyUnitCode = response.data.allGoods[0].CODE
  472. }
  473. //是否是报单中心
  474. this.isDec = response.data.isDec
  475. const settingObj = this.allGoods
  476. for (const i in this.allGoods) {
  477. this.storeNums[i] = 1
  478. settingObj[i].goodsNum = 0
  479. }
  480. this.tableData = Object.values(settingObj)
  481. const pageList = this.multipleSelection
  482. this.$nextTick(function() {
  483. for (const i in this.tableData) {
  484. for (const j in pageList) {
  485. if (pageList[j].ID === this.tableData[i].ID) {
  486. this.$data.storeNums[i] = pageList[j].goodsNum
  487. this.tableData[i].goodsNum = pageList[j].goodsNum
  488. break
  489. }
  490. }
  491. }
  492. })
  493. // 支付方式
  494. this.payList = response.data.sellType[0]['sell_type']
  495. // 支付方式的第一项默认选中
  496. this.form.payType = Object.values(this.payList)[1]['label']
  497. setTimeout(() => {
  498. this.loading = false
  499. }, 0.5 * 1000)
  500. }).catch(err => {
  501. console.log(err)
  502. this.loading = false
  503. })
  504. },
  505. // 商品详情
  506. handleProduct(row) {
  507. this.product = row
  508. this.product.taxAmount = tool.calculateTax(row.MARKET_PRICE, row.TAX_RATE)
  509. this.visibleProduct = true
  510. },
  511. // 选择商品计数
  512. handleInputNumber(current, row) {
  513. const pageList = this.multipleSelection
  514. let selectStatus = false
  515. for (const i in pageList) {
  516. if (pageList[i].ID === row.ID) {
  517. pageList[i].goodsNum = current
  518. selectStatus = true
  519. break
  520. }
  521. }
  522. if (selectStatus) {
  523. this.multipleSelection = pageList
  524. this.handleSureChange()
  525. }
  526. },
  527. // 统计商品
  528. handleSureChange() {
  529. if (this.multipleSelection.length > 0) {
  530. let accumulatorSellPrice = 0; let accumulatorPricePv = 0; let accumulatorTax = 0
  531. this.multipleSelection.forEach(accumulator => {
  532. accumulatorSellPrice += accumulator.MARKET_PRICE * accumulator.goodsNum
  533. accumulatorPricePv += Number(accumulator.PRICE_PV) * Number(accumulator.goodsNum)
  534. accumulatorTax += tool.calculateTax(Number(accumulator.MARKET_PRICE), Number(accumulator.TAX_RATE), Number(accumulator.goodsNum))
  535. })
  536. this.sellPriceSum = tool.formatPrice(accumulatorSellPrice)
  537. this.pricePvSum = tool.formatPrice(accumulatorPricePv)
  538. this.taxSum = tool.formatPrice(accumulatorTax)
  539. this.display = true
  540. } else {
  541. this.sellPriceSum = this.pricePvSum = this.taxSum = 0.00
  542. this.display = true
  543. }
  544. },
  545. // 选择商品
  546. handleSelectionChange(val) {
  547. let idx = -1; let num
  548. for (const i in this.tableData) {
  549. for (const v in val) {
  550. if (val[v].ID === this.tableData[i].ID) {
  551. idx = i
  552. num = this.storeNums[idx]
  553. val[v]['goodsNum'] = num
  554. break
  555. }
  556. }
  557. }
  558. this.multipleSelection = val
  559. // 计算统计
  560. this.handleSureChange()
  561. },
  562. // 选择收货地址
  563. choseAddress(addressId) {
  564. this.addressId = addressId
  565. // 设置运费
  566. this.setFreight()
  567. // 计算价格
  568. this.getSumMoney()
  569. },
  570. // 切换支付方式
  571. chosePayType(type) {
  572. this.payType = type
  573. },
  574. // 关闭支付回调
  575. handleClose() {
  576. this.$confirm(this.$t('shop.confirmClose')).then(_ => {
  577. deleteApproachOrder({ orderSn: this.form.orderSn }).then(() => {
  578. // 关闭支付模态框
  579. this.visible = false
  580. // 关闭购物车
  581. this.visibleShoppingCart = false
  582. this.submitButtonStat = false
  583. })
  584. })
  585. },
  586. // 支付成功回调
  587. processPayment() {
  588. // 关闭支付页面
  589. this.visible = false
  590. this.payStackLoading = false
  591. // 显示支付成功模态框
  592. this.payDialog = true
  593. // 启动支付成功倒计时
  594. this.handleCountdown()
  595. },
  596. // 倒计时结束跳转
  597. handleOrderList() {
  598. this.$router.push({ path: `/shop/member-order` })
  599. },
  600. // 启动倒计时
  601. handleCountdown() {
  602. // 创建定时器
  603. setInterval(() => {
  604. // 每隔1秒把time的值减一,赋值给span标签
  605. this.countdown--
  606. if (this.countdown === 0) {
  607. // 倒计时结束,跳转到订单列表
  608. this.$router.push({ path: `/shop/member-order` })
  609. }
  610. }, 1000)
  611. },
  612. // 会员查询
  613. handleChkRecUser() {
  614. this.form.conUserName = ''
  615. this.conRealName = '-'
  616. this.form.autoPlace = ''
  617. if (this.form.recUserName) {
  618. this.loading = true
  619. fetchFullInfo({ userName: this.form.recUserName }).then(response => {
  620. this.recRealName = response.data.REAL_NAME
  621. this.loading = false
  622. }).catch(() => {
  623. this.recRealName = '-'
  624. this.loading = false
  625. })
  626. }
  627. },
  628. // 返回方式
  629. wayChange() {
  630. if (this.form.way === 'pickup') {
  631. this.areaDisabled = true
  632. this.addressDisabled = true
  633. } else {
  634. this.areaDisabled = false
  635. this.addressDisabled = false
  636. }
  637. },
  638. // 会员报单/BA升级
  639. onSubmit() {
  640. if (!this.form.decLv) {
  641. this.$message({
  642. message: this.$t('profile.selectLevel'),
  643. type: 'error'
  644. })
  645. return false
  646. }
  647. if (this.isDec == 0 && !this.form.decUserName) {
  648. this.$message({
  649. message: this.$t('shop.declarationCenterNumberTips'),
  650. type: 'error'
  651. })
  652. return false
  653. }
  654. // 已选择商品
  655. this.selectProduct()
  656. if (this.multipleSelection.length <= 0) {
  657. this.$message.error(this.$t('shop.chooseTips'))
  658. return false
  659. }
  660. // 余额
  661. const amountBalance = this.userBalance[this.form.payType] || 0
  662. // 余额是否充足
  663. if ((this.form.payType === 'cash') && ((amountBalance - this.payAmount) < 0)) {
  664. // 账户类型提示信息
  665. const payListArray = Array.from(this.form.payType)
  666. const account = payListArray.filter(item => {
  667. return this.form.payType === item.label
  668. })
  669. const accountType = account[0] && account[0].name || ''
  670. this.$message({
  671. message: accountType + this.$t('shop.balanceNotAllow'),
  672. type: 'error'
  673. })
  674. return false
  675. }
  676. this.submitButtonStat = true
  677. const params = {
  678. consignee: this.form.consignee,
  679. acceptMobile: this.form.acceptMobile,
  680. province: this.form.areaSelected[0] ? this.form.areaSelected[0] : '',
  681. city: this.form.areaSelected[1] ? this.form.areaSelected[1] : '',
  682. county: this.form.areaSelected[2] ? this.form.areaSelected[2] : '',
  683. address: this.form.address,
  684. decType: this.form.decType,
  685. insertUserName: this.form.insertUserName,
  686. decLv: this.form.decLv,
  687. realName: this.form.realName,
  688. decUserName: this.form.decUserName,
  689. conUserName: this.form.conUserName,
  690. recUserName: this.form.recUserName,
  691. insertUserIdCard: this.form.insertUserIdCard,
  692. openBank: this.form.openBank,
  693. bankAddress: this.form.bankAddress,
  694. mobile: this.form.mobile,
  695. email: this.form.email,
  696. cityName: this.form.cityName,
  697. lgaName: this.form.lgaName,
  698. bankProvince: this.form.bankAreaSelected[0] ? this.form.bankAreaSelected[0] : '',
  699. bankCity: this.form.bankAreaSelected[1] ? this.form.bankAreaSelected[1] : '',
  700. bankCounty: this.form.bankAreaSelected[2] ? this.form.bankAreaSelected[2] : '',
  701. bankNo: this.form.bankNo,
  702. password: this.form.password,
  703. payPassword: this.form.payPassword,
  704. packageId: this.form.packageId,
  705. goodsId: this.form.goodsId,
  706. goodsNum: this.form.goodsNum,
  707. location: 1, //自动安置
  708. decWay: this.decWay,
  709. payType: this.form.payType,
  710. countryId: this.form.countryId,
  711. languageId: this.form.languageId
  712. }
  713. createWelcomePack(params).then(response => {
  714. if (this.form.payType !== 'pay_stack') {
  715. // 余额支付
  716. this.$message({
  717. message: this.$t('common.successfully'),
  718. type: 'success'
  719. })
  720. this.submitButtonStat = false
  721. this.$router.push({ path: `/shop/member-order` })
  722. } else {
  723. this.submitButtonStat = false
  724. this.payForm.orderSn = response.data.SN
  725. this.payForm.amount = response.data.ORDER_AMOUNT
  726. this.payForm.metadata.custom_fields[0].value = response.data.SN
  727. this.payForm.email = response.data.EMAIL
  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>