customerDetails.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708
  1. <template>
  2. <view :class="mask ? 'tl-show': ''">
  3. <!-- <u-navbar :title="title" :autoBack="true" :placeholder="true" leftIconColor="#fff"
  4. :titleStyle="{ color: '#ffffff' }" bgColor="#FD4B09">
  5. <template slot="right">
  6. <u-icon name="checkmark" color="#fff" @click="submit"></u-icon>
  7. </template>
  8. </u-navbar> -->
  9. <u-cell-group :border="false">
  10. <u-cell :border="false" center title="基础信息"></u-cell>
  11. </u-cell-group>
  12. <u--form labelPosition="left" :model="form" ref="form" labelWidth="150rpx"
  13. style="margin-top: 10rpx;margin-bottom: 150rpx;">
  14. <view style="width: calc(96%);margin: 0 auto;background-color: #fff;border-radius: 20rpx;">
  15. <view style="padding: 0 10rpx;">
  16. <u-form-item label="公司名称" prop="cname" borderBottom>
  17. <u-input v-model="form.cname" inputAlign="right" border="none" placeholder="请输入" />
  18. </u-form-item>
  19. <u-form-item label="联系人" prop="cname" borderBottom>
  20. <u-input v-model="form.attn" inputAlign="right" border="none" placeholder="请输入" />
  21. </u-form-item>
  22. <u-form-item label="联系电话" prop="cname" borderBottom>
  23. <u-input v-model="form.tel" inputAlign="right" border="none" placeholder="请输入" />
  24. </u-form-item>
  25. <u-form-item label="业务员" :borderBottom="false"
  26. @click="filterAll(['adminProfilesName','adminProfiles'])">
  27. <u-input border="none" inputAlign="right" suffixIcon="plus-circle" disabled
  28. v-model="form.adminProfilesName" disabledColor="#ffffff" />
  29. </u-form-item>
  30. <u-form-item label="送货地址" :borderBottom="false"
  31. @click="filterAll(['corpsAddrList','corpsAddrList'])">
  32. ({{form.corpsAddrList.length}})
  33. <u-input border="none" inputAlign="right" suffixIcon="plus-circle" disabled
  34. disabledColor="#ffffff" />
  35. </u-form-item>
  36. <u-cell-group :border="false">
  37. <u-swipe-action>
  38. <u-swipe-action-item :options="options" v-for="(item,index) in form.corpsAddrList"
  39. :key="index" @click="address(index)">
  40. <u-cell @click="change(item,index)" :iconStyle="{ color: '#fd4b09' }" :titleStyle="{
  41. width:'550rpx',
  42. overflow:'hidden',
  43. whiteSpace: 'nowrap',
  44. textOverflow: 'ellipsis',
  45. oTextOverflow:'ellipsis'
  46. }" :icon="item.type == 0?'map':'car'" :title="item.detailedAddress" :isLink="true"
  47. :borderBottom="form.corpsAddrList.length-1 == index?false:true">
  48. </u-cell>
  49. </u-swipe-action-item>
  50. </u-swipe-action>
  51. </u-cell-group>
  52. </view>
  53. </view>
  54. <u-cell-group :border="false">
  55. <u-cell :border="false" center title="类别信息" :arrow-direction="category==false?'up':'down'"
  56. :value="category==false?'展开':'收起'" :isLink="true" @click="category = !category"></u-cell>
  57. </u-cell-group>
  58. <view style="width: calc(96%);margin: 0 auto;background-color: #fff;border-radius: 20rpx;">
  59. <view style="padding: 0 10rpx;">
  60. <u-form-item label="客户类别" :borderBottom="category==false?false:true"
  61. @click="filterAll(['corpsTypeName','corpsTypeId'])">
  62. <u-input v-model="form.corpsTypeName" inputAlign="right" border="none" placeholder="请选择"
  63. disabled disabledColor="#ffffff">
  64. <template slot="suffix" style="text-align: center;">
  65. <u-icon name="plus-circle" size="18" @click.native.stop="newCategory()"></u-icon>
  66. </template>
  67. </u-input>
  68. </u-form-item>
  69. <u-form-item label="商城价格" :borderBottom="category==false?false:true"
  70. @click="filterAll(['shoppingMall','shoppingMall'])">
  71. <u-input v-model="form.shoppingMall" inputAlign="right" border="none" placeholder="请选择"
  72. disabled disabledColor="#ffffff">
  73. </u-input>
  74. </u-form-item>
  75. <view v-if="category">
  76. <u-form-item label="客户标签1" prop="mailbox" borderBottom labelWidth="180rpx">
  77. <u-input v-model="form.labels[0]" inputAlign="right" border="none" placeholder="请输入" />
  78. </u-form-item>
  79. <u-form-item label="客户标签2" prop="mailbox" labelWidth="180rpx" borderBottom>
  80. <u-input v-model="form.labels[1]" inputAlign="right" border="none" placeholder="请输入" />
  81. </u-form-item>
  82. <u-form-item label="客户标签3" prop="mailbox" labelWidth="180rpx" borderBottom>
  83. <u-input v-model="form.labels[2]" inputAlign="right" border="none" placeholder="请输入" />
  84. </u-form-item>
  85. <u-form-item label="客户标签4" prop="mailbox" labelWidth="180rpx" :borderBottom="false">
  86. <u-input v-model="form.labels[3]" inputAlign="right" border="none" placeholder="请输入" />
  87. </u-form-item>
  88. </view>
  89. </view>
  90. </view>
  91. <u-cell-group :border="false">
  92. <u-cell :border="false" center title="商务信息" :arrow-direction="customer==false?'up':'down'"
  93. :value="customer==false?'展开':'收起'" :isLink="true" @click="customer = !customer"></u-cell>
  94. </u-cell-group>
  95. <view style="width: calc(96%);margin: 0 auto;background-color: #fff;border-radius: 20rpx;" v-if="customer">
  96. <view style="padding: 0 10rpx;">
  97. <u-form-item label="客户经理" prop="mailbox" borderBottom>
  98. <u-input v-model="form.adminProfiles" inputAlign="right" border="none" placeholder="请输入" />
  99. </u-form-item>
  100. <u-form-item label="预付款" prop="mailbox" borderBottom>
  101. <u-input v-model="form.creditGrant" inputAlign="right" border="none" placeholder="请输入" />
  102. </u-form-item>
  103. <u-form-item label="欠款额度" prop="mailbox" borderBottom>
  104. <u-input v-model="form.arrears" inputAlign="right" border="none" placeholder="请输入" />
  105. </u-form-item>
  106. <u-form-item label="银行帐号" prop="mailbox" borderBottom>
  107. <u-input v-model="form.accountNo" inputAlign="right" border="none" placeholder="请输入" />
  108. </u-form-item>
  109. <u-form-item label="开户银行" prop="mailbox" :borderBottom="false">
  110. <u-input v-model="form.accountBank" inputAlign="right" border="none" placeholder="请输入" />
  111. </u-form-item>
  112. </view>
  113. </view>
  114. <u-cell-group :border="false">
  115. <u-cell :border="false" center title="图片信息" :arrow-direction="enclosure==false?'up':'down'"
  116. :value="enclosure==false?'展开':'收起'" :isLink="true" @click="enclosure = !enclosure"></u-cell>
  117. </u-cell-group>
  118. <view style="width: calc(96%);margin: 0 auto;background-color: #fff;border-radius: 20rpx;" v-if="enclosure">
  119. <view style="padding: 10rpx 10rpx;">
  120. <u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple
  121. :maxCount="10"></u-upload>
  122. </view>
  123. </view>
  124. </u--form>
  125. <view style="width: 100%;position: fixed;bottom: 0;background-color: #fff;">
  126. <view style="width: 96%;;margin: 20rpx auto;">
  127. <u-button @click="submit" type="success" color="#fd4b09" shape="circle" text="确认提交"></u-button>
  128. </view>
  129. </view>
  130. <u-popup :show="show" @close="show = false,mask = false,formTwo = {}" closeable :closeOnClickOverlay="false"
  131. zIndex="10070">
  132. <view style="width: 96%;margin: auto auto;margin-top: 20rpx;padding-bottom: 20rpx;">
  133. <text>添加地址</text>
  134. <!-- <u-divider style="margin-bottom: 10rpx;"></u-divider>
  135. <view style="display: flex;justify-content: space-around;" :key="addrType">
  136. <view style="padding-bottom: 10rpx;" :class="addrType == 0?'selectedAddress':''"
  137. @click="selected(0)">客户地址</view>
  138. <view style="padding-bottom: 10rpx;" :class="addrType == 1?'selectedAddress':''"
  139. @click="selected(1)">物流地址</view>
  140. </view>
  141. <u-divider style="margin-top: 0rpx;"></u-divider> -->
  142. <u--form labelPosition="left" :model="formTwo" labelWidth="150rpx">
  143. <!-- <u-form-item label="省市区" borderBottom @click="filterAll(['addr','addr'])">
  144. <u-input v-model="formTwo.addr" border="none" placeholder="请选择" suffixIcon="arrow-right"
  145. disabled disabledColor="#ffffff" />
  146. </u-form-item> -->
  147. <u-form-item label="详细地址" borderBottom>
  148. <u-input v-model="formTwo.detailedAddress" border="none" placeholder="请输入">
  149. <template slot="suffix">
  150. <u-button @tap="getMap" type="success" size="mini" icon="map" color="#fd4b09"></u-button>
  151. </template>
  152. </u-input>
  153. </u-form-item>
  154. </u--form>
  155. <view style="display: flex;justify-content: space-between;padding-top: 20rpx;">
  156. <!-- <view style="width: 45%;">
  157. <u-button text="全部清空" type="warning" @click="confirmEmptying"></u-button>
  158. </view> -->
  159. <view style="width: 96%;margin: 0 auto;background-color: red;">
  160. <u-button text="保存" type="primary" @click="confirmSearch" color="#fd4b09"></u-button>
  161. </view>
  162. </view>
  163. </view>
  164. </u-popup>
  165. <u-picker :show="dropDown" ref="uPicker" :defaultIndex="[0,0,0]" :columns="columns" :keyName="keyName"
  166. @cancel="dropDown = false,mask = false" @confirm="confirm" @change="changeHandler">
  167. </u-picker>
  168. </view>
  169. </template>
  170. <script>
  171. import {
  172. urbanAreas,
  173. customerType,
  174. saveChanges,
  175. queryDetail,
  176. removeAddr,
  177. removeFile,
  178. gainUser
  179. } from "@/api/views/customer/index.js"
  180. import http from '@/http/api.js'
  181. import {
  182. clientId,
  183. clientSecret
  184. } from '@/common/setting'
  185. export default {
  186. data() {
  187. return {
  188. form: {
  189. labels: ["", "", "", ""],
  190. corpsAddrList: []
  191. },
  192. customer: false,
  193. enclosure: false,
  194. category: false,
  195. title: "创建客户",
  196. options: [{
  197. text: '删除',
  198. style: {
  199. backgroundColor: '#fc0107',
  200. }
  201. }],
  202. formTwo: {},
  203. mask: false,
  204. show: false,
  205. dropDown: false,
  206. columns: [],
  207. keyName: "",
  208. addrType: 0,
  209. fileList1: [],
  210. screen: [],
  211. type: false,
  212. iNdex: 0
  213. }
  214. },
  215. onLoad(data) {
  216. if (data.id) {
  217. uni.setNavigationBarTitle({
  218. title: '客户详情'
  219. })
  220. this.title = "客户详情"
  221. this.query(data.id)
  222. } else {
  223. uni.setNavigationBarTitle({
  224. title: '创建客户'
  225. })
  226. this.title = "创建客户"
  227. }
  228. },
  229. methods: {
  230. newCategory(){
  231. uni.$u.route('/pages/views/product/customerType',{
  232. corpType:'KH'
  233. });
  234. },
  235. getMap() {
  236. let this_ = this
  237. uni.chooseLocation({
  238. success: function(res) {
  239. this_.$set(this_.formTwo, "dimension", res.latitude)
  240. this_.$set(this_.formTwo, "longitude", res.longitude)
  241. this_.$set(this_.formTwo, "detailedAddress", res.address)
  242. }
  243. });
  244. },
  245. change(item, index) {
  246. this.show = true
  247. this.mask = true
  248. this.formTwo = item
  249. this.iNdex = index
  250. this.type = true
  251. this.addrType = item.type
  252. // let this_ = this
  253. // uni.chooseLocation({
  254. // success: function (res) {
  255. // this_.$set(this_.form.corpsAddrList[index],"dimension",res.latitude)
  256. // this_.$set(this_.form.corpsAddrList[index],"longitude",res.longitude)
  257. // this_.$set(this_.form.corpsAddrList[index],"detailedAddress",res.address)
  258. // }
  259. // });
  260. },
  261. query(id) {
  262. uni.showLoading({
  263. title: '加载中',
  264. mask: true
  265. });
  266. queryDetail({
  267. id: id
  268. }).then(res => {
  269. this.form = res.data
  270. this.fileList1 = res.data.corpsFiles
  271. this.form.labels = res.data.labels ? res.data.labels.split(',') : []
  272. if (this.form.labels.length < 4) {
  273. for (let item in 4) {
  274. this.form.labels.push("")
  275. }
  276. }
  277. uni.hideLoading();
  278. })
  279. },
  280. //提交
  281. submit() {
  282. if (!this.form.cname) {
  283. return uni.showToast({
  284. title: '客户名称不能为空',
  285. icon: 'none',
  286. mask: true
  287. });
  288. }
  289. if (!this.form.attn) {
  290. return uni.showToast({
  291. title: '联系人不能为空',
  292. icon: 'none',
  293. mask: true
  294. });
  295. }
  296. if (!this.form.tel) {
  297. return uni.showToast({
  298. title: '电话不能为空',
  299. icon: 'none',
  300. mask: true
  301. });
  302. }
  303. if (this.form.corpsAddrList.length == 0) {
  304. return uni.showToast({
  305. title: '送货地址不能为空',
  306. icon: 'none',
  307. mask: true
  308. });
  309. }
  310. if (!this.form.corpsTypeId) {
  311. return uni.showToast({
  312. title: '客户类别不能为空',
  313. icon: 'none',
  314. mask: true
  315. });
  316. }
  317. let data = {
  318. ...this.form,
  319. code: this.form.cname,
  320. corpsFiles: this.fileList1,
  321. billType:'1'
  322. }
  323. data.corpsFiles.forEach(item => delete item.status)
  324. let this_ = this
  325. uni.showModal({
  326. title: '提示',
  327. content: '是否确认保存',
  328. success: function(rest) {
  329. if (rest.confirm == true) {
  330. uni.showLoading({
  331. title: '加载中',
  332. mask: true
  333. });
  334. let labels = []
  335. for (let item of data.labels) {
  336. if (item) {
  337. labels.push(item)
  338. }
  339. }
  340. saveChanges({
  341. ...data,
  342. corpType: "KH",
  343. labels: labels.join(',')
  344. }).then(res => {
  345. uni.showToast({
  346. icon: "none",
  347. title: '保存成功',
  348. mask: true
  349. });
  350. setTimeout(function() {
  351. this_.query(res.data.id)
  352. }, 1000);
  353. uni.hideLoading();
  354. })
  355. }
  356. }
  357. })
  358. },
  359. //集合筛选条件
  360. filterAll(screen) {
  361. this.screen = screen
  362. switch (screen[1]) {
  363. case "corpsAddrList":
  364. this.show = true
  365. this.mask = true
  366. break;
  367. case "corpsTypeId":
  368. this.mask = true
  369. customerType({
  370. corpType: 'KH',
  371. parentId: 0
  372. }).then(res => {
  373. this.columns = [res.data]
  374. if (res.data.length > 0) {
  375. if (res.data[0].hasChildren == true) {
  376. customerType({
  377. corpType: 'KH',
  378. parentId: res.data[0].id
  379. }).then(rest => {
  380. this.columns.push(rest.data)
  381. this.dropDown = true
  382. this.keyName = "title"
  383. })
  384. } else {
  385. this.dropDown = true
  386. this.keyName = "title"
  387. }
  388. }
  389. })
  390. break;
  391. case "addr":
  392. uni.showLoading({
  393. title: '加载中',
  394. mask: true
  395. });
  396. urbanAreas({
  397. parentCode: "00"
  398. }).then(res => {
  399. this.columns = [res.data]
  400. urbanAreas({
  401. parentCode: res.data[0].id
  402. }).then(rest => {
  403. this.columns.push(rest.data)
  404. urbanAreas({
  405. parentCode: rest.data[0].id
  406. }).then(resth => {
  407. this.columns.push(resth.data)
  408. this.dropDown = true
  409. this.keyName = "name"
  410. uni.hideLoading();
  411. })
  412. })
  413. })
  414. this.show = true
  415. this.mask = true
  416. break;
  417. case "adminProfiles":
  418. uni.showLoading({
  419. title: '加载中',
  420. mask: true
  421. });
  422. gainUser().then(res => {
  423. this.columns = [res.data]
  424. this.dropDown = true
  425. this.keyName = "name"
  426. this.mask = true
  427. uni.hideLoading();
  428. })
  429. break;
  430. case "shoppingMall":
  431. uni.showLoading({
  432. title: '加载中',
  433. mask: true
  434. });
  435. this.$u.api.getWorkDicts('mall_price').then(res => {
  436. this.columns = [res.data]
  437. this.dropDown = true
  438. this.keyName = "dictValue"
  439. this.mask = true
  440. uni.hideLoading();
  441. })
  442. break;
  443. }
  444. },
  445. changeHandler(e) {
  446. const {
  447. columnIndex,
  448. index,
  449. // 微信小程序无法将picker实例传出来,只能通过ref操作
  450. picker = this.$refs.uPicker
  451. } = e
  452. if (this.screen[1] == "corpsTypeId") {
  453. if(e.value[e.columnIndex].hasChildren){
  454. if (e.columnIndex == 0) {
  455. uni.showLoading({
  456. title: '加载中',
  457. mask: true
  458. });
  459. customerType({
  460. parentId: e.value[e.columnIndex].id
  461. }).then(res => {
  462. picker.setColumnValues(1, res.data)
  463. if (res.data[0].hasChildren == true) {
  464. customerType({
  465. parentId: res.data[0].id
  466. }).then(rest => {
  467. picker.setColumnValues(2, rest.data)
  468. uni.hideLoading();
  469. })
  470. } else {
  471. uni.hideLoading();
  472. }
  473. })
  474. }
  475. if (e.columnIndex == 1) {
  476. uni.showLoading({
  477. title: '加载中',
  478. mask: true
  479. });
  480. customerType({
  481. parentId: e.value[e.columnIndex].id
  482. }).then(res => {
  483. picker.setColumnValues(2, res.data)
  484. uni.hideLoading();
  485. })
  486. }
  487. }else{
  488. if(e.columnIndex == 0){
  489. if(this.columns.length > 1){
  490. if(!e.value[e.columnIndex].hasChildren){
  491. let data = this.columns[0]
  492. this.columns = [data]
  493. }
  494. }
  495. }
  496. }
  497. }
  498. if (this.screen[1] == "addr") {
  499. if (e.columnIndex == 0) {
  500. uni.showLoading({
  501. title: '加载中',
  502. mask: true
  503. });
  504. urbanAreas({
  505. parentCode: e.value[e.columnIndex].id
  506. }).then(rest => {
  507. picker.setColumnValues(1, rest.data)
  508. urbanAreas({
  509. parentCode: rest.data[0].id
  510. }).then(resth => {
  511. picker.setColumnValues(2, resth.data)
  512. uni.hideLoading();
  513. })
  514. })
  515. }
  516. if (e.columnIndex == 1) {
  517. uni.showLoading({
  518. title: '加载中',
  519. mask: true
  520. });
  521. urbanAreas({
  522. parentCode: e.value[e.columnIndex].id
  523. }).then(rest => {
  524. picker.setColumnValues(2, rest.data)
  525. uni.hideLoading();
  526. })
  527. }
  528. }
  529. },
  530. // 确认选中
  531. confirm(e) {
  532. if (this.screen[1] == "addr") {
  533. this.formTwo.addr = e.value[0].name + e.value[1].name + e.value[2].name
  534. } else if (this.screen[1] == "corpsTypeId") {
  535. this.form[this.screen[0]] = e.value[e.values.length-1].title
  536. this.form[this.screen[1]] = e.value[e.values.length-1].id
  537. } else if (this.screen[1] == "shoppingMall") {
  538. this.form[this.screen[0]] = e.value[e.values.length-1].dictKey
  539. this.form[this.screen[1]] = e.value[e.values.length-1].dictValue
  540. } else if(this.screen[1] == "adminProfiles") {
  541. this.form[this.screen[0]] = e.value[0].name
  542. this.form[this.screen[1]] = e.value[0].id
  543. } else {
  544. this.formTwo[this.screen[0]] = e.value[0].cname
  545. this.formTwo[this.screen[1]] = e.value[0].id
  546. }
  547. this.dropDown = false
  548. this.mask = false
  549. this.columns = []
  550. },
  551. //删除地址
  552. address(index) {
  553. let this_ = this
  554. uni.showModal({
  555. title: '提示',
  556. content: '是否确认删除',
  557. success: function(rest) {
  558. if (rest.confirm == true) {
  559. if (this_.form.corpsAddrList[index].id) {
  560. uni.showLoading({
  561. title: '加载中',
  562. mask: true
  563. });
  564. removeAddr({
  565. ids: this_.form.corpsAddrList[index].id
  566. }).then(res => {
  567. this_.form.corpsAddrList.splice(index, 1);
  568. uni.hideLoading();
  569. })
  570. } else {
  571. this_.form.corpsAddrList.splice(index, 1);
  572. }
  573. }
  574. }
  575. })
  576. },
  577. //切换地址信息
  578. selected(type) {
  579. // this.addrType = type
  580. this.$set(this, 'addrType', type)
  581. this.formTwo = {}
  582. },
  583. //保存地址
  584. confirmSearch() {
  585. if (!this.formTwo.detailedAddress) {
  586. return uni.showToast({
  587. title: '请输入详细地址',
  588. icon: 'none',
  589. mask: true
  590. });
  591. }
  592. if (this.type) {
  593. this.form.corpsAddrList[this.iNdex] = {
  594. ...this.formTwo,
  595. type: this.addrType
  596. }
  597. this.type = false
  598. } else {
  599. this.form.corpsAddrList.push({
  600. ...this.formTwo,
  601. type: this.addrType
  602. })
  603. }
  604. this.formTwo = {}
  605. this.addrType = 0
  606. this.show = false
  607. this.mask = false
  608. },
  609. // 删除图片
  610. deletePic(event) {
  611. let this_ = this
  612. uni.showModal({
  613. title: '提示',
  614. content: '是否确认删除',
  615. success: function(rest) {
  616. if (rest.confirm == true) {
  617. if (this_[`fileList${event.name}`][event.index].id) {
  618. removeFile({
  619. ids: this_[`fileList${event.name}`][event.index].id
  620. }).then(res => {
  621. this_[`fileList${event.name}`].splice(event.index, 1)
  622. })
  623. } else {
  624. this_[`fileList${event.name}`].splice(event.index, 1)
  625. }
  626. }
  627. }
  628. })
  629. },
  630. // 新增图片
  631. async afterRead(event) {
  632. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  633. let lists = [].concat(event.file)
  634. let fileListLen = this[`fileList${event.name}`].length
  635. lists.map((item) => {
  636. this[`fileList${event.name}`].push({
  637. ...item,
  638. status: 'uploading',
  639. message: '上传中'
  640. })
  641. })
  642. for (let i = 0; i < lists.length; i++) {
  643. const result = await this.uploadFilePromise(lists[i].url)
  644. let item = this[`fileList${event.name}`][fileListLen]
  645. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  646. status: 'success',
  647. sort: this.fileList1.length,
  648. fileName: JSON.parse(result).data.originalName,
  649. url: JSON.parse(result).data.link
  650. }))
  651. fileListLen++
  652. }
  653. },
  654. uploadFilePromise(url) {
  655. return new Promise((resolve, reject) => {
  656. let a = uni.uploadFile({
  657. url: http.config.baseURL +
  658. '/blade-resource/oss/endpoint/put-file', // 仅为示例,非真实的接口地址
  659. filePath: url,
  660. name: 'file',
  661. formData: {
  662. user: 'test'
  663. },
  664. header: {
  665. // 客户端认证参数
  666. 'Authorization': 'Basic ' + Base64.encode(clientId + ':' + clientSecret),
  667. 'Blade-Auth': 'bearer ' + uni.getStorageSync('accessToken')
  668. },
  669. success: (res) => {
  670. setTimeout(() => {
  671. resolve(res.data)
  672. }, 1000)
  673. }
  674. });
  675. })
  676. },
  677. }
  678. }
  679. </script>
  680. <style lang="scss" scoped>
  681. .tl-show {
  682. overflow: hidden;
  683. position: fixed;
  684. height: 100%;
  685. width: 100%;
  686. }
  687. ::v-deep .u-cell__body {
  688. padding: 0rpx 25rpx;
  689. margin: 10rpx 0;
  690. }
  691. ::v-deep .u-cell__title-text {
  692. color: #244e96;
  693. }
  694. ::v-deep .u-form-item__body__left__content__label {
  695. color: #fd4b09;
  696. }
  697. .selectedAddress {
  698. border-bottom: 1rpx solid #fd4b09;
  699. color: #fd4b09;
  700. }
  701. </style>