customerDetails.vue 24 KB

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