member-upgrade.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. <template>
  2. <div v-loading="loading">
  3. <div class="white-box" style="padding: 15px 25px;">
  4. <el-row :gutter="20">
  5. <el-col :xs="24" :sm="16" :lg="16">
  6. <el-form ref="form" :model="form" :label-position="labelPosition" label-width="180px" class="form-page">
  7. <el-form-item :label="$t('shop.memberCode')" prop="insertUserName">
  8. <el-input v-model="form.insertUserName" :placeholder="$t('user.enterMemberCode')" :rules="{ required: true, message: $t('user.enterMemberCode'), trigger: 'blur' }" @blur="fetchUpgradeInfo" />
  9. </el-form-item>
  10. <el-form-item :label="$t('profile.memberLevel')">
  11. <el-input v-model="form.userDecName" disabled />
  12. </el-form-item>
  13. <el-form-item :label="$t('shop.memberName')">
  14. <el-input v-model="form.userRealName" disabled />
  15. </el-form-item>
  16. <el-form-item :label="$t('profile.joiningDate')">
  17. <el-input v-model="form.addAt" disabled />
  18. </el-form-item>
  19. <el-form-item v-if="!isMax" :label="$t('profile.upgradeWay')">
  20. <el-input v-model="form.upgradeFunc" disabled />
  21. </el-form-item>
  22. <el-form-item v-if="!isMax" prop="upgradeValue" :label="$t('profile.toUpgradeLevel')">
  23. <el-select v-model="form.upgradeValue" :placeholder="$t('profile.selectLevel')" style="width: 100%;" @change="handleChangeLevel($event)">
  24. <el-option v-for="item in upgradeOption" :key="item.ID" :label="item.LEVEL_NAME" :value="{value:item.ID, diffPv:item.REPAIR_PV}" />
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item v-if="!isMax" :label="$t('profile.topUpBV')">
  28. <el-input v-model="needDiffPv" disabled />
  29. </el-form-item>
  30. <el-form-item v-if="!isMax">
  31. <template slot="label">{{ $t('profile.upgradePurchaseProduct') }}</template>
  32. <el-tabs v-model="decWay" type="border-card" style="position: relative; width: 100%;">
  33. <el-tab-pane :label="$t('shop.product')" name="2">
  34. <el-collapse v-model="activeName" accordion>
  35. <el-collapse-item name="product">
  36. <el-table :data="tableData" :show-header="false" @selection-change="handleSelectionChange">
  37. <el-table-column type="selection" width="30" align="center" style="top: -30px;" />
  38. <el-table-column align="center">
  39. <template slot-scope="{row, $index}">
  40. <el-container>
  41. <el-aside width="80px" style=" padding: 0; margin-bottom: 0; background-color: #ffffff;">
  42. <el-image style="width: 80px; height: 80px" :src="tool.getArImage(row.COVER, '/files/')" />
  43. </el-aside>
  44. <el-main style="padding: 0;">
  45. <div style="text-align: left; line-height: 25px;">
  46. <span style="font-weight: bold; cursor: pointer;" @click="handleProduct(row)">{{ row.GOODS_NAME }}</span><br>
  47. <span>{{ row.GOODS_NO }}</span><br>
  48. <span style="color: tomato;">{{ $t('shop.salesPrice') }}:{{row.CODE}} {{ row.SELL_PRICE | toThousandFilter }}</span><br>
  49. <span>{{ $t('shop.productBV') }}:{{ row.PRICE_PV | toThousandFilter }}</span><br>
  50. <span>{{ $t('shop.marketPrice') }}:{{row.CODE}} {{ row.MARKET_PRICE | toThousandFilter }}</span><br>
  51. <span style="display: inline-block; float: right; ">
  52. <el-input-number v-model="storeNums[$index]" size="mini" :min="1" :max="Number(row.STORE_NUMS)" @change="handleInputNumber($event, row)" />
  53. </span>
  54. <br>
  55. </div>
  56. </el-main>
  57. </el-container>
  58. </template>
  59. </el-table-column>
  60. </el-table>
  61. </el-collapse-item>
  62. </el-collapse>
  63. <div class="white-box-footer">
  64. <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;">
  65. <div style="margin-right: 1rem; display: inline-block;">{{ $t('shop.productPrice') }}:{{currencyUnitCode}} {{ sellPriceSum | toThousandFilter }}</div>
  66. <div style="margin-right: 1rem; display: inline-block;">{{ $t('shop.productBV') }}:{{ pricePvSum | toThousandFilter }}</div>
  67. <div style="display: inline-block;">{{ $t('shop.taxAmount') }}:{{currencyUnitCode}} {{ taxSum }}</div>
  68. </div>
  69. </div>
  70. </el-tab-pane>
  71. </el-tabs>
  72. </el-form-item>
  73. <el-form-item v-if="!isMax" :label="$t('shop.recipientName')">
  74. <el-input v-model="form.consignee" />
  75. </el-form-item>
  76. <el-form-item v-if="!isMax" :label="$t('shop.phoneNumber')">
  77. <el-input v-model="form.acceptMobile" />
  78. </el-form-item>
  79. <el-form-item v-if="!isMax" prop="areaSelected" :label="$t('config.state')">
  80. <el-cascader v-model="form.areaSelected" size="large" :options="regionData" style="width: 100%;" />
  81. </el-form-item>
  82. <el-form-item v-if="!isMax" :label="$t('config.localGovernmentArea')">
  83. <el-input v-model="form.lgaName" />
  84. </el-form-item>
  85. <el-form-item v-if="!isMax" :label="$t('config.city')">
  86. <el-input v-model="form.cityName" />
  87. </el-form-item>
  88. <el-form-item v-if="!isMax" :label="$t('config.detailedAddress')">
  89. <el-input v-model="form.address" />
  90. </el-form-item>
  91. <el-form-item v-if="!isMax" :label="$t('common.note')">
  92. <el-input v-model="form.remark" type="textarea" />
  93. </el-form-item>
  94. <el-form-item v-if="!isMax" :label="$t('shop.paymentMethod')" required style="padding-left: 0;">
  95. <el-radio-group v-model="form.payType" @change="chosePayType">
  96. <el-radio v-for="(item, index) in payList" :key="index" border :label="item.label" style="margin: 5px;">
  97. {{ item.name }}<span v-if="item.label === 'cash'" style="color: tomato;">( {{currencyUnitCode}} {{ userBalance.cash | toThousandFilter }})</span>
  98. </el-radio>
  99. </el-radio-group>
  100. </el-form-item>
  101. <el-form-item v-if="!isMax">
  102. <el-button size="small" type="primary" :loading="submitButtonStat" @click="onSubmit">{{ $t('common.save') }}</el-button>
  103. </el-form-item>
  104. </el-form>
  105. </el-col>
  106. </el-row>
  107. </div>
  108. <!-- payStack模态框 -->
  109. <el-dialog v-loading="payStackLoading" :title="$t('shop.goPay')" :visible.sync="visible" :width="payStackScreenWidth" :before-close="handleClose">
  110. <section>
  111. <el-form :model="payForm">
  112. <el-form-item :label="$t('user.email')" label-width="100px" required>
  113. <el-input v-model="payForm.email" autocomplete="off" />
  114. </el-form-item>
  115. <el-form-item :label="$t('shop.amount')" label-width="100px" required>
  116. <el-input v-model="payForm.amount" autocomplete="off" readonly />
  117. </el-form-item>
  118. </el-form>
  119. </section>
  120. <paystack
  121. :firstname="payForm.firstname"
  122. :lastname="payForm.lastname"
  123. :amount="payForm.amount * 100"
  124. :email="payForm.email"
  125. :metadata="payForm.metadata"
  126. :currency="payForm.currency"
  127. :paystackkey="payForm.publicKey"
  128. :reference="reference"
  129. :channels="channels"
  130. :callback="processPayment"
  131. :close="handleClose"
  132. >
  133. <el-button type="primary" size="small">{{ $t('shop.goPay') }}</el-button>
  134. </paystack>
  135. <el-button type="danger" size="small" class="cancelButton" style="margin-left: 10px;" @click="handleClose">{{ $t('common.cancel') }}</el-button>
  136. </el-dialog>
  137. <!-- 倒计时页面 -->
  138. <el-dialog :title="$t('common.hint')" :visible.sync="payDialog" :width="payStackScreenWidth" :show-close="false" :close="handleOrderList">
  139. <el-card shadow="always">
  140. <el-result icon="success" :title="$t('common.successfully')" :sub-title="$t('shop.successOrderTips')">
  141. <template slot="extra">
  142. <el-button type="primary" size="medium" @click="handleOrderList">{{ $t('shop.goBack') }}({{ countdown }})</el-button>
  143. </template>
  144. </el-result>
  145. </el-card>
  146. </el-dialog>
  147. <!-- 商品详情 -->
  148. <el-dialog :title="product.GOODS_NO" :visible.sync="visibleProduct" :width="screenWidth" style="margin-top: -95px;">
  149. <el-row :gutter="20">
  150. <el-col :xs="24" :sm="12" :lg="12">
  151. <el-image style="width: 100%; height: 100%" :style="imageStyle" :src="tool.getArImage(product.COVER, '/files/')" />
  152. </el-col>
  153. <el-col :xs="24" :sm="12" :lg="12">
  154. <div style="text-align: left; line-height: 50px; font-size: 16px;">
  155. <span style="font-weight: bold; font-size: 20px;">{{ product.GOODS_NAME }}</span><br>
  156. <span style="font-weight: bold; font-size: 15px;">{{ $t('shop.productCode') }}:{{ product.GOODS_NO }}</span><br>
  157. <span style="color: tomato;">{{ $t('shop.salesPrice') }}:{{currencyUnitCode}} {{ product.SELL_PRICE }}</span><br>
  158. <span>{{ $t('shop.marketPrice') }}:{{currencyUnitCode}} {{ product.MARKET_PRICE }}</span><br>
  159. <span>{{ $t('shop.productBV') }}:{{ product.PRICE_PV | toThousandFilter }}</span><br>
  160. <span>{{ $t('shop.taxRate') }}:{{ product.TAX_RATE / 100 }}</span><br>
  161. <span>{{ $t('shop.taxAmount') }}:{{currencyUnitCode}} {{ product.taxAmount | toThousandFilter }}</span><br>
  162. <span>{{ $t('shop.inventory') }}:{{ product.STORE_NUMS }}</span>
  163. </div>
  164. </el-col>
  165. </el-row>
  166. </el-dialog>
  167. </div>
  168. </template>
  169. <script>
  170. import { deleteApproachOrder } from '@/api/shop'
  171. import { fetchFullInfo, fetchSendUpgrade, fetchUpgrade, fetchUpgradeInfo } from '@/api/user'
  172. import Pagination from '@/components/Pagination'
  173. import waves from '@/directive/waves'
  174. import region from '@/store/modules/region'
  175. import { getScreenWidth } from '@/utils'
  176. import tool from '@/utils/tool'
  177. import usersInfo from '@/utils/usersInfo'
  178. import paystack from 'vue-paystack'
  179. export default {
  180. name: 'UpgradeManagement',
  181. components: { Pagination, paystack },
  182. directives: { waves },
  183. filters: {
  184. bvFilter(row) {
  185. return tool.calculateBV(row.REAL_PV, row.BUY_NUMS)
  186. },
  187. taxAmountFilter(row) {
  188. return tool.calculateTax(row.REAL_PRICE, row.BUY_NUMS)
  189. },
  190. priceAmountFilter(row) {
  191. return tool.formatPrice(row.REAL_PRICE * row.BUY_NUMS)
  192. },
  193. statusFilter(status) {
  194. const statusMap = {
  195. Unpaid: 'info',
  196. Paid: 'success'
  197. }
  198. return statusMap[status]
  199. }
  200. },
  201. data() {
  202. return {
  203. tool: tool,
  204. nowPerf: '',
  205. nextPerf: '',
  206. decUserName: '',
  207. needDiffPv: '',
  208. isMax: true,
  209. upgradeOption: [],
  210. toLevel: '',
  211. currentRow: null,
  212. decWay: '2',
  213. regionData: [],
  214. form: {
  215. address: '',
  216. areaSelected: [],
  217. consignee: '',
  218. upgradeFunc: '',
  219. upgradeValue: '',
  220. addAt: '',
  221. userRealName: '',
  222. userDecName: '',
  223. remark: '',
  224. realName: '',
  225. decLv: '',
  226. insertUserName: '',
  227. decUserName: '',
  228. recUserName: '',
  229. conUserName: '',
  230. insertUserIdCard: '',
  231. packageId: '',
  232. goodsId: [],
  233. goodsNum: [],
  234. province: '',
  235. // city: '',
  236. // county: '',
  237. lgaName: '',
  238. cityName: '',
  239. acceptMobile: '',
  240. payType: ''
  241. },
  242. num: 1,
  243. allDecPackage: {},
  244. loading: false,
  245. submitButtonStat: false,
  246. submitButton: false,
  247. allGoods: [],
  248. goodsNums: [],
  249. numList: [],
  250. sell_price_sum: 0.00,
  251. price_pv_sum: 0.00,
  252. payList: [],
  253. sn: '',
  254. payDialog: false,
  255. countdown: 5,
  256. visible: false,
  257. payStackLoading: false,
  258. channels: ['card', 'bank', 'ussd', 'qr'], // eft(南非) mobile_money(加纳)
  259. payForm: {
  260. publicKey: process.env.VUE_APP_BASE_PAY_STACK_PUBLIC_KEY,
  261. currency: 'NGN',
  262. firstname: usersInfo.userName(),
  263. lastname: '',
  264. email: usersInfo.userEmail(),
  265. amount: 0, // kobo
  266. orderSn: '',
  267. metadata: {
  268. cart_id: '',
  269. custom_fields: [
  270. {
  271. display_name: 'orderSn',
  272. variable_name: 'orderSn',
  273. value: this.sn
  274. },
  275. {
  276. display_name: 'orderType',
  277. variable_name: 'orderType',
  278. value: 'userUpgrade'
  279. }
  280. ]
  281. }
  282. },
  283. addressId: '',
  284. selfPickUpAddressId: '100000000000000000',
  285. shippingAddressList: [],
  286. visibleProduct: false,
  287. product: {
  288. GOODS_NAME: '',
  289. GOODS_NO: '',
  290. COVER: '',
  291. SELL_PRICE: 0,
  292. PRICE_PV: 0,
  293. TAX_RATE: 0,
  294. taxAmount: 0
  295. },
  296. imageStyle: 'margin-top: 0px;',
  297. screenWidth: getScreenWidth() > 600 ? '50%' : getScreenWidth() + 'px',
  298. labelPosition: getScreenWidth() > 500 ? 'right' : 'top',
  299. payStackScreenWidth: getScreenWidth() > 500 ? '450px' : getScreenWidth() + 'px',
  300. multipleSelection: [],
  301. sellPriceSum: 0.00,
  302. pricePvSum: 0.00,
  303. taxSum: 0.00,
  304. storeNums: [],
  305. tableData: null,
  306. payAmount: 0.00,
  307. userBalance: {
  308. cash: 0
  309. },
  310. activeName: 'product',
  311. currencyUnitCode: ""
  312. }
  313. },
  314. computed: {
  315. // PayStack混淆串
  316. reference() {
  317. let text = ''
  318. const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
  319. for (let i = 0; i < 10; i++) {
  320. text += possible.charAt(Math.floor(Math.random() * possible.length))
  321. }
  322. return text
  323. }
  324. },
  325. created() {
  326. // this.fetchUpgrade()
  327. },
  328. mounted() {
  329. },
  330. methods: {
  331. fetchUpgrade() {
  332. this.loading = true
  333. fetchUpgrade({
  334. userName: this.form.insertUserName
  335. }).then(response => {
  336. this.loading = false
  337. this.userBalance = response.data.userBalance
  338. this.decUserName = response.data.decUserName
  339. this.allDecPackage = response.data.allDecPackage
  340. this.allGoods = response.data.allGoods
  341. this.regionData = response.data.region
  342. const settingObj = this.allGoods
  343. for (const i in this.allGoods) {
  344. this.storeNums[i] = 1
  345. settingObj[i].goodsNum = 0
  346. }
  347. if(response.data.allGoods && response.data.allGoods.length > 0){
  348. this.currencyUnitCode = response.data.allGoods[0].CODE
  349. }
  350. this.tableData = Object.values(settingObj)
  351. const pageList = this.multipleSelection
  352. this.$nextTick(function() {
  353. for (const i in this.tableData) {
  354. for (const j in pageList) {
  355. if (pageList[j].ID === this.tableData[i].ID) {
  356. this.$data.storeNums[i] = pageList[j].goodsNum
  357. this.tableData[i].goodsNum = pageList[j].goodsNum
  358. break
  359. }
  360. }
  361. }
  362. })
  363. // 支付方式
  364. this.payList = response.data.sellType[0]['sell_type']
  365. // 支付方式的第一项默认选中
  366. this.form.payType = Object.values(this.payList)[1]['label']
  367. setTimeout(() => {
  368. this.loading = false
  369. }, 0.5 * 1000)
  370. })
  371. },
  372. fetchUpgradeInfo() {
  373. if (!this.form.insertUserName) {
  374. this.$message({
  375. message: this.$t('user.enterMemberCode'),
  376. type: 'error'
  377. })
  378. return false
  379. }
  380. this.loading = true
  381. fetchUpgradeInfo({ userName: this.form.insertUserName }).then(response => {
  382. this.loading = false
  383. this.form.addAt = response.data.baseInfo.ADD_AT
  384. this.form.userRealName = response.data.baseInfo.REAL_NAME
  385. this.form.userDecName = response.data.baseInfo.DEC_NAME
  386. this.isMax = response.data.baseInfo.IS_MAX
  387. this.upgradeOption = response.data.baseInfo.LEVEL_LIST
  388. this.form.upgradeFunc = response.data.baseInfo.UPGRADE_FUNC
  389. this.nowPerf = response.data.baseInfo.NOW_PERF
  390. this.nextPerf = response.data.baseInfo.NEXT_PERF
  391. this.fetchUpgrade()
  392. setTimeout(() => {
  393. this.loading = false
  394. }, 0.5 * 1000)
  395. })
  396. },
  397. // 商品详情
  398. handleProduct(row) {
  399. this.product = row
  400. this.product.taxAmount = tool.calculateTax(row.SELL_PRICE, row.TAX_RATE)
  401. this.visibleProduct = true
  402. },
  403. // 选择商品计数
  404. handleInputNumber(current, row) {
  405. const pageList = this.multipleSelection
  406. let selectStatus = false
  407. for (const i in pageList) {
  408. if (pageList[i].ID === row.ID) {
  409. pageList[i].goodsNum = current
  410. selectStatus = true
  411. break
  412. }
  413. }
  414. if (selectStatus) {
  415. this.multipleSelection = pageList
  416. this.handleSureChange()
  417. }
  418. },
  419. // 统计商品
  420. handleSureChange() {
  421. if (this.multipleSelection.length > 0) {
  422. let accumulatorSellPrice = 0; let accumulatorPricePv = 0; let accumulatorTax = 0
  423. this.multipleSelection.forEach(accumulator => {
  424. accumulatorSellPrice += accumulator.SELL_PRICE * accumulator.goodsNum
  425. accumulatorPricePv += Number(accumulator.PRICE_PV) * Number(accumulator.goodsNum)
  426. accumulatorTax += tool.calculateTax(Number(accumulator.SELL_PRICE), Number(accumulator.TAX_RATE), Number(accumulator.goodsNum))
  427. })
  428. this.sellPriceSum = tool.formatPrice(accumulatorSellPrice)
  429. this.pricePvSum = tool.formatPrice(accumulatorPricePv)
  430. this.taxSum = tool.formatPrice(accumulatorTax)
  431. this.display = true
  432. } else {
  433. this.sellPriceSum = this.pricePvSum = this.taxSum = 0.00
  434. this.display = true
  435. }
  436. },
  437. // 选择商品
  438. handleSelectionChange(val) {
  439. let idx = -1; let num
  440. for (const i in this.tableData) {
  441. for (const v in val) {
  442. if (val[v].ID === this.tableData[i].ID) {
  443. idx = i
  444. num = this.storeNums[idx]
  445. val[v]['goodsNum'] = num
  446. break
  447. }
  448. }
  449. }
  450. this.multipleSelection = val
  451. // 计算统计
  452. this.handleSureChange()
  453. },
  454. // 选择收货地址
  455. choseAddress(addressId) {
  456. this.addressId = addressId
  457. // 设置运费
  458. this.setFreight()
  459. // 计算价格
  460. this.getSumMoney()
  461. },
  462. // 切换支付方式
  463. chosePayType(type) {
  464. this.payType = type
  465. },
  466. // 关闭支付回调
  467. handleClose() {
  468. this.$confirm(this.$t('shop.confirmClose')).then(_ => {
  469. deleteApproachOrder({ orderSn: this.form.orderSn }).then(() => {
  470. // 关闭支付模态框
  471. this.visible = false
  472. // 关闭购物车
  473. this.visibleShoppingCart = false
  474. this.submitButtonStat = false
  475. })
  476. })
  477. },
  478. // 支付成功回调
  479. processPayment() {
  480. // 关闭支付页面
  481. this.visible = false
  482. this.payStackLoading = false
  483. // 显示支付成功模态框
  484. this.payDialog = true
  485. // 启动支付成功倒计时
  486. this.handleCountdown()
  487. },
  488. // 倒计时结束跳转
  489. handleOrderList() {
  490. this.$router.push({ path: `/shop/member-order` })
  491. },
  492. // 启动倒计时
  493. handleCountdown() {
  494. // 创建定时器
  495. setInterval(() => {
  496. // 每隔1秒把time的值减一,赋值给span标签
  497. this.countdown--
  498. if (this.countdown === 0) {
  499. // 倒计时结束,跳转到订单列表
  500. this.$router.push({ path: `/shop/member-order` })
  501. }
  502. }, 1000)
  503. },
  504. // 会员查询
  505. handleChkRecUser() {
  506. this.form.conUserName = ''
  507. this.conRealName = '-'
  508. this.form.autoPlace = ''
  509. if (this.form.recUserName) {
  510. this.loading = true
  511. fetchFullInfo({ userName: this.form.recUserName }).then(response => {
  512. this.recRealName = response.data.REAL_NAME
  513. this.loading = false
  514. }).catch(() => {
  515. this.recRealName = '-'
  516. this.loading = false
  517. })
  518. }
  519. },
  520. // 返回方式
  521. wayChange() {
  522. if (this.form.way === 'pickup') {
  523. this.areaDisabled = true
  524. this.addressDisabled = true
  525. } else {
  526. this.areaDisabled = false
  527. this.addressDisabled = false
  528. }
  529. },
  530. // 提交订单
  531. onSubmit() {
  532. if (!this.form.insertUserName) {
  533. this.$message({
  534. message: this.$t('user.enterMemberCode'),
  535. type: 'error'
  536. })
  537. return false
  538. }
  539. if (!this.toLevel) {
  540. this.$message({
  541. message: this.$t('profile.selectLevel'),
  542. type: 'error'
  543. })
  544. return false
  545. }
  546. // 已选择商品
  547. this.selectProduct()
  548. if (this.multipleSelection.length <= 0) {
  549. this.$message.error(this.$t('shop.chooseTips'))
  550. return false
  551. }
  552. // 余额
  553. const amountBalance = this.userBalance[this.form.payType] || 0
  554. // 余额是否充足
  555. if ((this.form.payType === 'cash') && ((amountBalance - this.payAmount) < 0)) {
  556. // 账户类型提示信息
  557. const payListArray = Array.from(this.form.payType)
  558. const account = payListArray.filter(item => {
  559. return this.form.payType === item.label
  560. })
  561. const accountType = account[0] && account[0].name || ''
  562. this.$message({
  563. message: accountType + this.$t('shop.balanceNotAllow'),
  564. type: 'error'
  565. })
  566. return false
  567. }
  568. this.submitButtonStat = true
  569. const params = {
  570. decUserName: this.decUserName,
  571. packageId: this.form.packageId,
  572. goodsId: this.form.goodsId,
  573. goodsNum: this.form.goodsNum,
  574. location: this.form.location,
  575. decWay: this.decWay,
  576. decLv: this.toLevel,
  577. insertUserName: this.form.insertUserName,
  578. remark: this.form.remark,
  579. address: this.form.address,
  580. consignee: this.form.consignee,
  581. acceptMobile: this.form.acceptMobile,
  582. province: this.form.areaSelected[0] ? this.form.areaSelected[0] : '',
  583. lgaName: this.form.lgaName,
  584. cityName: this.form.cityName,
  585. nowPerf: this.nowPerf,
  586. nextPerf: this.nextPerf,
  587. payType: this.form.payType
  588. }
  589. fetchSendUpgrade(params).then(response => {
  590. if (this.form.payType !== 'pay_stack') {
  591. // 余额支付
  592. this.$message({
  593. message: this.$t('common.successfully'),
  594. type: 'success'
  595. })
  596. this.submitButtonStat = false
  597. this.$router.push({ path: `/shop/member-order` })
  598. } else {
  599. // PayStack支付
  600. this.submitButtonStat = false
  601. this.payForm.orderSn = response.data.SN
  602. this.payForm.amount = response.data.ORDER_AMOUNT
  603. this.payForm.metadata.custom_fields[0].value = response.data.SN
  604. this.visible = true
  605. }
  606. }).catch(err => {
  607. this.$message({
  608. message: err,
  609. type: 'error'
  610. })
  611. this.submitButtonStat = false
  612. })
  613. },
  614. // 已选择商品
  615. selectProduct() {
  616. this.payAmount = 0
  617. this.form.goodsId = []
  618. this.form.goodsNum = []
  619. this.multipleSelection.map((item) => {
  620. this.form.goodsId.push(item.ID)
  621. this.form.goodsNum.push(item.goodsNum)
  622. this.payAmount += item.goodsNum * item.SELL_PRICE
  623. })
  624. },
  625. // 等级变更
  626. handleChangeLevel(data) {
  627. const { value, diffPv } = data
  628. this.needDiffPv = diffPv
  629. this.toLevel = value
  630. }
  631. }
  632. }
  633. </script>
  634. <style>
  635. .el-table th.el-table__cell > .cell {
  636. white-space: nowrap;
  637. }
  638. .el-table td.el-table__cell > .cell {
  639. word-break: keep-all;
  640. white-space: pre-wrap;
  641. }
  642. .el-radio.is-bordered + .el-radio.is-bordered {
  643. margin: 5px;
  644. }
  645. .el-radio--medium.is-bordered {
  646. margin: 5px;
  647. }
  648. </style>