newCard.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. <template>
  2. <view class="content">
  3. <view class="content1 relative">
  4. <view class="relative">
  5. <image :src="imgList[selectIndex].dictLabel" mode="widthFix" style="width: 100%;"></image>
  6. </view>
  7. <view class="absolute card-content style1" v-if="imgList[selectIndex].dictSort==1">
  8. <view class="left">
  9. <u--image :showLoading="true" :src="cardInfo.headSculpture" width="66px" height="66px" shape="circle" v-if="cardInfo.headSculpture"></u--image>
  10. <u--image :showLoading="true" src="/./../static/imgs/card/defaulthead.png" width="66px" height="66px" shape="circle" v-else></u--image>
  11. </view>
  12. <view class="right">
  13. <view class="row1">
  14. <text class="name">{{cardInfo.name}}</text>
  15. <text class="post">{{cardInfo.post}}</text>
  16. </view>
  17. <view class="row2">
  18. {{cardInfo.companyName}}
  19. </view>
  20. <view class="row3 flex">
  21. <uni-icons type="map-filled" size="20" style="margin-right: 20rpx;" color="#5e6d82"></uni-icons>{{ cardInfo.province }}{{ cardInfo.city }}{{ cardInfo.area }}
  22. </view>
  23. <view class="row4 flex">
  24. <uni-icons type="phone-filled" size="20" style="margin-right: 20rpx;" color="#5e6d82"></uni-icons>{{ cardInfo.phone }}
  25. </view>
  26. <!-- <view class="">
  27. 备注
  28. </view> -->
  29. </view>
  30. </view>
  31. <view class="absolute card-content style1 flex-between" v-if="imgList[selectIndex].dictSort==2">
  32. <view class="right">
  33. <view class="row1">
  34. <text class="name">{{cardInfo.name}}</text>
  35. <text class="post">{{cardInfo.post}}</text>
  36. </view>
  37. <view class="row2">
  38. {{cardInfo.companyName}}
  39. </view>
  40. <view class="row3 flex">
  41. <uni-icons type="map-filled" size="20" style="margin-right: 20rpx;" color="#5e6d82"></uni-icons>{{ cardInfo.province }}{{ cardInfo.city }}{{ cardInfo.area }}
  42. </view>
  43. <view class="row4 flex">
  44. <uni-icons type="phone-filled" size="20" style="margin-right: 20rpx;" color="#5e6d82"></uni-icons>{{ cardInfo.phone }}
  45. </view>
  46. <!-- <view class="">
  47. 备注
  48. </view> -->
  49. </view>
  50. <view class="left">
  51. <u--image :showLoading="true" :src="cardInfo.headSculpture" width="66px" height="66px" shape="circle" v-if="cardInfo.headSculpture"></u--image>
  52. <u--image :showLoading="true" src="/./../static/imgs/card/defaulthead.png" width="66px" height="66px" shape="circle" v-else></u--image>
  53. </view>
  54. </view>
  55. <view class="absolute card-content style2" v-if="imgList[selectIndex].dictSort==3">
  56. <view class="top">
  57. <u--image :showLoading="true" :src="cardInfo.headSculpture" width="66px" height="66px" shape="circle" v-if="cardInfo.headSculpture"></u--image>
  58. <u--image :showLoading="true" src="/./../static/imgs/card/defaulthead.png" width="66px" height="66px" shape="circle" v-else></u--image>
  59. </view>
  60. <view class="bottom flex">
  61. <view class="left">
  62. <view class="row1">
  63. <text class="name">{{cardInfo.name}}</text>
  64. <text class="post">{{cardInfo.post}}</text>
  65. </view>
  66. <view class="row2">
  67. {{cardInfo.companyName}}
  68. </view>
  69. </view>
  70. <view class="right">
  71. <view class="row1 flex">
  72. <uni-icons type="map-filled" size="20" style="margin-right: 20rpx;" color="#5e6d82"></uni-icons>{{ cardInfo.province }}{{ cardInfo.city }}{{ cardInfo.area }}
  73. </view>
  74. <view class="row2 flex">
  75. <uni-icons type="phone-filled" size="20" style="margin-right: 20rpx;" color="#5e6d82"></uni-icons>{{ cardInfo.phone }}
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. <view class="absolute card-content style2" v-if="imgList[selectIndex].dictSort==4">
  81. <view class="top">
  82. <view class="row1">
  83. <text class="name">{{cardInfo.name}}</text>
  84. <text class="post">{{cardInfo.post}}</text>
  85. </view>
  86. <view class="row2">
  87. {{cardInfo.companyName}}
  88. </view>
  89. </view>
  90. <view class="bottom flex">
  91. <view class="left">
  92. <u--image :showLoading="true" :src="cardInfo.headSculpture" width="66px" height="66px" shape="circle" v-if="cardInfo.headSculpture"></u--image>
  93. <u--image :showLoading="true" src="/./../static/imgs/card/defaulthead.png" width="66px" height="66px" shape="circle" v-else></u--image>
  94. </view>
  95. <view class="right">
  96. <view class="row1 flex">
  97. <uni-icons type="map-filled" size="20" style="margin-right: 20rpx;" color="#5e6d82"></uni-icons>{{ cardInfo.province }}{{ cardInfo.city }}{{ cardInfo.area }}
  98. </view>
  99. <view class="row2 flex">
  100. <uni-icons type="phone-filled" size="20" style="margin-right: 20rpx;" color="#5e6d82"></uni-icons>{{ cardInfo.phone }}
  101. </view>
  102. </view>
  103. </view>
  104. </view>
  105. </view>
  106. <view class="change-template">
  107. 切换模板
  108. </view>
  109. <view class="img-list">
  110. <view class="img-item" v-for="(item,index) in imgList" @click="changeTemplate(index)">
  111. <image :src="item.dictValue" class="img-item" :key="index"></image>
  112. <image src="../../static/imgs/card/dh.png" class="dh" v-if="selectIndex==index"></image>
  113. </view>
  114. </view>
  115. <view class="change-template">
  116. 名片信息
  117. </view>
  118. <view class="content2">
  119. <view class="flex flex-between row">
  120. <view class="left">
  121. 名片标识
  122. </view>
  123. <u--input v-model="cardInfo.cardBusiness" border="none" placeholder="输入名片标识" inputAlign='right'></u--input>
  124. </view>
  125. <view class="flex flex-between row">
  126. <view class="left">
  127. 姓名
  128. </view>
  129. <u--input v-model="cardInfo.name" border="none" placeholder="输入姓名" inputAlign='right'></u--input>
  130. </view>
  131. <view class="flex flex-between row">
  132. <view class="left">
  133. 职务
  134. </view>
  135. <u--input v-model="cardInfo.post" border="none" placeholder="输入职务,不超过8个字符" inputAlign='right'></u--input>
  136. </view>
  137. <view class="flex flex-between row">
  138. <view class="left">
  139. 公司/机构名称
  140. </view>
  141. <u--input v-model="cardInfo.companyName" border="none" placeholder="输入公司/机构名称" inputAlign='right'></u--input>
  142. </view>
  143. <view class="flex flex-between row" @click="placeSelect();hideKeyboard()">
  144. <view class="left">
  145. 地址
  146. </view>
  147. <view v-if="cardInfo.province">{{ cardInfo.province }}{{ cardInfo.city }}{{ cardInfo.area }}</view>
  148. <view class="" v-else>
  149. <text>选择地址 </text>
  150. <image src="../../static/imgs/card/yjt.png" mode="" style="margin-left:10rpx;width:12rpx;height: 21rpx;"></image>
  151. </view>
  152. </view>
  153. <view class="flex flex-between row">
  154. <view class="left">
  155. 详细地址
  156. </view>
  157. <u--input v-model="cardInfo.detailedAddress" border="none" placeholder="输入详细地址,不超过15个字" inputAlign='right'></u--input>
  158. </view>
  159. <view class="flex flex-between row">
  160. <view class="left">
  161. 联系电话
  162. </view>
  163. <u--input v-model="cardInfo.phone" border="none" placeholder="输入联系电话" inputAlign='right'></u--input>
  164. </view>
  165. <!-- <u-form-item label="地址" prop="userInfo.name" borderBottom>
  166. <view @click="showPicker">选择地址</view>
  167. <view>{{ province }}{{ city }}{{ area }}</view>
  168. </u-form-item> -->
  169. <view class="flex flex-between row">
  170. <view class="left">
  171. 上传企业logo或个人头像
  172. </view>
  173. <view class="right">
  174. <u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple
  175. :maxCount="1"></u-upload>
  176. </view>
  177. </view>
  178. </view>
  179. <view class="bottom">
  180. <button @click='$u.debounce(submit, 500)' class='button' type="default">提交</button>
  181. </view>
  182. <city-picker ref="picker" mode="multiSelector" :list="areaData" :level="3" @confirm="finishSelectAddress">
  183. </city-picker>
  184. <u-modal :show="isSubmit" :content='content' @confirm="$u.debounce(confirmSubmit, 500)" showCancelButton
  185. @cancel="isSubmit=false" @close="isSubmit=false" closeOnClickOverlay></u-modal>
  186. <u-toast ref="uToast"></u-toast>
  187. </view>
  188. </template>
  189. <script>
  190. var that;
  191. import uploadImage from '@/components/ossutil/uploadFile.js';
  192. export default {
  193. onLoad() {
  194. that = this
  195. this.userInfo = uni.getStorageSync("userInfo")
  196. this.cardInfo.commonId = this.userInfo.id
  197. this.getList()
  198. },
  199. data() {
  200. return {
  201. selectIndex: 0,
  202. imgList:[],
  203. // imgList: [{
  204. // dictLabel: '/./../static/1.jpg',
  205. // dictValue: '/./../static/1.jpg'
  206. // },
  207. // {
  208. // dictLabel: '/./../static/2.jpg',
  209. // dictValue: '/./../static/2.jpg'
  210. // },
  211. // {
  212. // dictLabel: '/./../static/3.jpg',
  213. // dictValue: '/./../static/3.jpg'
  214. // }, {
  215. // dictLabel: '/./../static/4.jpg',
  216. // dictValue: '/./../static/4.jpg'
  217. // }, {
  218. // dictLabel: '/./../static/5.jpg',
  219. // dictValue: '/./../static/5.jpg'
  220. // }
  221. // ],
  222. isSubmit: false,
  223. content: '确定提交名片信息?',
  224. userInfo: {},
  225. fileList1: [],
  226. cardInfo: {
  227. city:'',
  228. area:'',
  229. province:'',
  230. commonId: '',
  231. cardBusiness: '名片标识',
  232. name: '',
  233. post: '',
  234. companyName: '',
  235. location: '',
  236. detailedAddress: '',
  237. phone: '',
  238. headSculpture: '',
  239. currentBackground:'',
  240. cuttentTemplate:''
  241. }
  242. };
  243. },
  244. methods: {
  245. changeTemplate(index) {
  246. this.selectIndex = index
  247. this.cardInfo.currentBackground = this.imgList[index].dictLabel
  248. this.cardInfo.cuttentTemplate = this.imgList[index].dictSort
  249. },
  250. getList() {
  251. this.$request.baseRequest('admin.dictData', 'list', {
  252. dictType: "card_template"
  253. }, failres => {
  254. console.log('res+++++', failres.errmsg)
  255. this.$refs.uToast.show({
  256. type: 'error',
  257. message: failres.errmsg,
  258. })
  259. uni.hideLoading()
  260. }).then(res => {
  261. console.log("img", res)
  262. this.imgList = res.data.items
  263. if(!this.cardInfo.currentBackground&&!this.cardInfo.cuttentTemplate){
  264. this.cardInfo.currentBackground = this.imgList[0].dictLabel
  265. this.cardInfo.cuttentTemplate = this.imgList[0].dictSort
  266. }
  267. })
  268. },
  269. placeSelect() {
  270. uni.chooseLocation({
  271. success: function(res) {
  272. console.log(res);
  273. that.cardInfo.location = res.latitude + ',' + res.longitude
  274. let _address = that.$helper.formatLocation(res.address)
  275. that.cardInfo.province = _address.Province
  276. that.cardInfo.city = _address.City
  277. that.cardInfo.area = _address.Country
  278. that.cardInfo.detailedAddress = _address.Village
  279. }
  280. });
  281. },
  282. hideKeyboard() {
  283. uni.hideKeyboard()
  284. },
  285. // 删除图片
  286. deletePic(event) {
  287. this[`fileList${event.name}`].splice(event.index, 1)
  288. },
  289. // 新增图片
  290. async afterRead(event) {
  291. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  292. let lists = [].concat(event.file)
  293. let fileListLen = this[`fileList${event.name}`].length
  294. lists.map((item) => {
  295. this[`fileList${event.name}`].push({
  296. ...item,
  297. status: 'uploading',
  298. message: '上传中'
  299. })
  300. })
  301. for (let i = 0; i < lists.length; i++) {
  302. const result = await this.uploadFilePromise(lists[i].url)
  303. let item = this[`fileList${event.name}`][fileListLen]
  304. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  305. status: 'success',
  306. message: '',
  307. url: result
  308. }))
  309. fileListLen++
  310. }
  311. },
  312. uploadFilePromise(res) {
  313. return new Promise((resolve, reject) => {
  314. uploadImage(res, 'cardImages/',
  315. result => {
  316. that.cardInfo.headSculpture = result
  317. resolve(res)
  318. }
  319. )
  320. })
  321. },
  322. confirmSubmit() {
  323. this.$request.baseRequest('admin.unimall.cardManagementInfo', 'add', {
  324. cardManagementInfo: JSON.stringify(this.cardInfo)
  325. }, failres => {
  326. this.$refs.uToast.show({
  327. type: 'error',
  328. message: failres.errmsg,
  329. })
  330. uni.hideLoading()
  331. }).then(res => {
  332. this.isSubmit = false
  333. this.$refs.uToast.show({
  334. type: 'success',
  335. message: '提交成功!',
  336. })
  337. this.$request.baseRequest('admin.unimall.personalHomepageInfo', 'list', {
  338. page: 1,
  339. limit: 10,
  340. commonId: uni.getStorageSync("userInfo").id
  341. }, failres => {
  342. console.log('res+++++', failres.errmsg)
  343. this.$refs.uToast.show({
  344. type: 'error',
  345. message: failres.errmsg,
  346. })
  347. uni.hideLoading()
  348. }).then(res => {
  349. if (res.data.items.length > 0) {
  350. uni.navigateBack()
  351. } else {
  352. uni.navigateTo({
  353. url: '/pages/mySet/myHome'
  354. })
  355. }
  356. })
  357. })
  358. },
  359. submit() {
  360. this.isSubmit = true
  361. }
  362. }
  363. }
  364. </script>
  365. <style lang="scss" scoped>
  366. .content {
  367. padding: 20rpx;
  368. }
  369. .bgc0 {
  370. background: url('https://taohaoliang.oss-cn-beijing.aliyuncs.com/pcfiles/bgc1.png') no-repeat center;
  371. height: 380rpx;
  372. border-radius: 20rpx;
  373. }
  374. .bgc1 {
  375. background: url('https://taohaoliang.oss-cn-beijing.aliyuncs.com/pcfiles/bgc2.png') no-repeat center;
  376. height: 380rpx;
  377. border-radius: 20rpx;
  378. }
  379. .bgc2 {
  380. background: url('https://taohaoliang.oss-cn-beijing.aliyuncs.com/pcfiles/bgc3.png') no-repeat center;
  381. height: 380rpx;
  382. border-radius: 20rpx;
  383. }
  384. .bgc3 {
  385. background: url('https://taohaoliang.oss-cn-beijing.aliyuncs.com/pcfiles/bgc4.png') no-repeat center;
  386. height: 380rpx;
  387. border-radius: 20rpx;
  388. }
  389. .bgc4 {
  390. background: url('https://taohaoliang.oss-cn-beijing.aliyuncs.com/pcfiles/bgc5.png') no-repeat center;
  391. height: 380rpx;
  392. border-radius: 20rpx;
  393. }
  394. .img {
  395. width: 100rpx;
  396. }
  397. .change-template {
  398. margin: 46rpx 0 30rpx 0;
  399. font-size: 32rpx;
  400. font-weight: bold;
  401. color: #19191A;
  402. }
  403. .img-list {
  404. display: block;
  405. white-space: nowrap;
  406. overflow-x: auto;
  407. .dh {
  408. width: 32rpx;
  409. height: 32rpx;
  410. position: absolute;
  411. right: 8rpx;
  412. bottom: 8rpx;
  413. }
  414. .img-item {
  415. position: relative;
  416. width: 186rpx;
  417. height: 120rpx;
  418. display: inline-block;
  419. margin-right: 2 0rpx;
  420. border-radius: 20rpx;
  421. margin-right: 20rpx;
  422. }
  423. }
  424. .content2 {
  425. background-color: #fff;
  426. border-radius: 20rpx;
  427. padding:0 20rpx 0 20rpx;
  428. .row{
  429. padding: 20rpx;
  430. border-bottom: 1px solid #E6E5E5;
  431. }
  432. }
  433. .button{
  434. color: #fff;
  435. background-color: #112253;
  436. border-radius: 20rpx;
  437. margin: 40rpx 0;
  438. }
  439. .card-content{
  440. top: 20rpx;
  441. left: 20rpx;
  442. }
  443. .content1{
  444. .style1{
  445. display: flex;
  446. padding: 20rpx 30rpx;
  447. width: 85%;
  448. .left{
  449. width: 132rpx;
  450. height: 132rpx;
  451. border-radius: 50%;
  452. }
  453. .right{
  454. margin-left: 40rpx;
  455. .row1{
  456. .name{
  457. font-size: 38rpx;
  458. font-weight: bold;
  459. color: #040000;
  460. margin-right: 20rpx;
  461. }
  462. .post{
  463. font-size: 26rpx;
  464. font-weight: 500;
  465. color: #666666;
  466. }
  467. }
  468. .row2{
  469. margin-top: 20rpx;
  470. font-size: 24rpx;
  471. font-weight: bold;
  472. color: #323333;
  473. }
  474. .row3{
  475. margin-top: 30rpx;
  476. font-size: 24rpx;
  477. font-weight: 500;
  478. color: #323333;
  479. }
  480. }
  481. }
  482. .style2{
  483. padding:30rpx;
  484. .top{
  485. .row1{
  486. .name{
  487. font-size: 38rpx;
  488. font-weight: bold;
  489. color: #040000;
  490. margin-right: 20rpx;
  491. }
  492. .post{
  493. font-size: 26rpx;
  494. font-weight: 500;
  495. color: #666666;
  496. }
  497. }
  498. .row2{
  499. margin-top: 20rpx;
  500. font-size: 24rpx;
  501. font-weight: bold;
  502. color: #323333;
  503. }
  504. }
  505. .bottom{
  506. margin-top: 48rpx;
  507. .left{
  508. margin-right: 40rpx;
  509. .row1{
  510. .name{
  511. font-size: 38rpx;
  512. font-weight: bold;
  513. color: #040000;
  514. margin-right: 20rpx;
  515. }
  516. .post{
  517. font-size: 26rpx;
  518. font-weight: 500;
  519. color: #666666;
  520. }
  521. }
  522. .row2{
  523. margin-top: 20rpx;
  524. font-size: 24rpx;
  525. font-weight: bold;
  526. color: #323333;
  527. }
  528. }
  529. .right{
  530. .row1,.row2{
  531. font-size: 24rpx;
  532. font-weight: 500;
  533. color: #323333;
  534. }
  535. .row2{
  536. margin-top: 20rpx;
  537. }
  538. }
  539. }
  540. }
  541. }
  542. </style>