newCard.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  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="selectIndex==0">
  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="selectIndex==1">
  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="selectIndex==2">
  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="selectIndex==3">
  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. console.log(this.imgList[index].dictSort)
  247. this.selectIndex = index
  248. this.cardInfo.currentBackground = this.imgList[index].dictLabel
  249. this.cardInfo.cuttentTemplate = this.imgList[index].dictSort
  250. },
  251. getList() {
  252. this.$request.baseRequest('admin.dictData', 'list', {
  253. dictType: "card_template"
  254. }, failres => {
  255. console.log('res+++++', failres.errmsg)
  256. this.$refs.uToast.show({
  257. type: 'error',
  258. message: failres.errmsg,
  259. })
  260. uni.hideLoading()
  261. }).then(res => {
  262. console.log("img", res)
  263. this.imgList = res.data.items
  264. if(!this.cardInfo.currentBackground&&!this.cardInfo.cuttentTemplate){
  265. this.cardInfo.currentBackground = this.imgList[0].dictLabel
  266. this.cardInfo.cuttentTemplate = this.imgList[0].dictSort
  267. }
  268. })
  269. },
  270. placeSelect() {
  271. uni.chooseLocation({
  272. success: function(res) {
  273. console.log(res);
  274. that.cardInfo.location = res.latitude + ',' + res.longitude
  275. let _address = that.$helper.formatLocation(res.address)
  276. that.cardInfo.province = _address.Province
  277. that.cardInfo.city = _address.City
  278. that.cardInfo.area = _address.Country
  279. that.cardInfo.detailedAddress = _address.Village
  280. }
  281. });
  282. },
  283. hideKeyboard() {
  284. uni.hideKeyboard()
  285. },
  286. // 删除图片
  287. deletePic(event) {
  288. this[`fileList${event.name}`].splice(event.index, 1)
  289. },
  290. // 新增图片
  291. async afterRead(event) {
  292. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  293. let lists = [].concat(event.file)
  294. let fileListLen = this[`fileList${event.name}`].length
  295. lists.map((item) => {
  296. this[`fileList${event.name}`].push({
  297. ...item,
  298. status: 'uploading',
  299. message: '上传中'
  300. })
  301. })
  302. for (let i = 0; i < lists.length; i++) {
  303. const result = await this.uploadFilePromise(lists[i].url)
  304. let item = this[`fileList${event.name}`][fileListLen]
  305. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  306. status: 'success',
  307. message: '',
  308. url: result
  309. }))
  310. fileListLen++
  311. }
  312. },
  313. uploadFilePromise(res) {
  314. return new Promise((resolve, reject) => {
  315. uploadImage(res, 'cardImages/',
  316. result => {
  317. that.cardInfo.headSculpture = result
  318. resolve(res)
  319. }
  320. )
  321. })
  322. },
  323. confirmSubmit() {
  324. this.$request.baseRequest('admin.unimall.cardManagementInfo', 'add', {
  325. cardManagementInfo: JSON.stringify(this.cardInfo)
  326. }, failres => {
  327. this.$refs.uToast.show({
  328. type: 'error',
  329. message: failres.errmsg,
  330. })
  331. uni.hideLoading()
  332. }).then(res => {
  333. this.isSubmit = false
  334. this.$refs.uToast.show({
  335. type: 'success',
  336. message: '提交成功!',
  337. })
  338. this.$request.baseRequest('admin.unimall.personalHomepageInfo', 'list', {
  339. page: 1,
  340. limit: 10,
  341. commonId: uni.getStorageSync("userInfo").id
  342. }, failres => {
  343. console.log('res+++++', failres.errmsg)
  344. this.$refs.uToast.show({
  345. type: 'error',
  346. message: failres.errmsg,
  347. })
  348. uni.hideLoading()
  349. }).then(res => {
  350. if (res.data.items.length > 0) {
  351. uni.navigateBack()
  352. } else {
  353. uni.navigateTo({
  354. url: '/pages/mySet/myHome'
  355. })
  356. }
  357. })
  358. })
  359. },
  360. submit() {
  361. this.isSubmit = true
  362. }
  363. }
  364. }
  365. </script>
  366. <style lang="scss" scoped>
  367. .content {
  368. padding: 20rpx;
  369. }
  370. .bgc0 {
  371. background: url('https://taohaoliang.oss-cn-beijing.aliyuncs.com/pcfiles/bgc1.png') no-repeat center;
  372. height: 380rpx;
  373. border-radius: 20rpx;
  374. }
  375. .bgc1 {
  376. background: url('https://taohaoliang.oss-cn-beijing.aliyuncs.com/pcfiles/bgc2.png') no-repeat center;
  377. height: 380rpx;
  378. border-radius: 20rpx;
  379. }
  380. .bgc2 {
  381. background: url('https://taohaoliang.oss-cn-beijing.aliyuncs.com/pcfiles/bgc3.png') no-repeat center;
  382. height: 380rpx;
  383. border-radius: 20rpx;
  384. }
  385. .bgc3 {
  386. background: url('https://taohaoliang.oss-cn-beijing.aliyuncs.com/pcfiles/bgc4.png') no-repeat center;
  387. height: 380rpx;
  388. border-radius: 20rpx;
  389. }
  390. .bgc4 {
  391. background: url('https://taohaoliang.oss-cn-beijing.aliyuncs.com/pcfiles/bgc5.png') no-repeat center;
  392. height: 380rpx;
  393. border-radius: 20rpx;
  394. }
  395. .img {
  396. width: 100rpx;
  397. }
  398. .change-template {
  399. margin: 46rpx 0 30rpx 0;
  400. font-size: 32rpx;
  401. font-weight: bold;
  402. color: #19191A;
  403. }
  404. .img-list {
  405. display: block;
  406. white-space: nowrap;
  407. overflow-x: auto;
  408. .dh {
  409. width: 32rpx;
  410. height: 32rpx;
  411. position: absolute;
  412. right: 8rpx;
  413. bottom: 8rpx;
  414. }
  415. .img-item {
  416. position: relative;
  417. width: 186rpx;
  418. height: 120rpx;
  419. display: inline-block;
  420. margin-right: 2 0rpx;
  421. border-radius: 20rpx;
  422. margin-right: 20rpx;
  423. }
  424. }
  425. .content2 {
  426. background-color: #fff;
  427. border-radius: 20rpx;
  428. padding:0 20rpx 0 20rpx;
  429. .row{
  430. padding: 20rpx;
  431. border-bottom: 1px solid #E6E5E5;
  432. }
  433. }
  434. .button{
  435. color: #fff;
  436. background-color: #112253;
  437. border-radius: 20rpx;
  438. margin: 40rpx 0;
  439. }
  440. .card-content{
  441. top: 20rpx;
  442. left: 20rpx;
  443. }
  444. .content1{
  445. .style1{
  446. display: flex;
  447. padding: 20rpx 30rpx;
  448. width: 85%;
  449. .left{
  450. width: 132rpx;
  451. height: 132rpx;
  452. border-radius: 50%;
  453. }
  454. .right{
  455. margin-left: 40rpx;
  456. .row1{
  457. .name{
  458. font-size: 38rpx;
  459. font-weight: bold;
  460. color: #040000;
  461. margin-right: 20rpx;
  462. }
  463. .post{
  464. font-size: 26rpx;
  465. font-weight: 500;
  466. color: #666666;
  467. }
  468. }
  469. .row2{
  470. margin-top: 20rpx;
  471. font-size: 24rpx;
  472. font-weight: bold;
  473. color: #323333;
  474. }
  475. .row3{
  476. margin-top: 30rpx;
  477. font-size: 24rpx;
  478. font-weight: 500;
  479. color: #323333;
  480. }
  481. }
  482. }
  483. .style2{
  484. padding:30rpx;
  485. .top{
  486. .row1{
  487. .name{
  488. font-size: 38rpx;
  489. font-weight: bold;
  490. color: #040000;
  491. margin-right: 20rpx;
  492. }
  493. .post{
  494. font-size: 26rpx;
  495. font-weight: 500;
  496. color: #666666;
  497. }
  498. }
  499. .row2{
  500. margin-top: 20rpx;
  501. font-size: 24rpx;
  502. font-weight: bold;
  503. color: #323333;
  504. }
  505. }
  506. .bottom{
  507. margin-top: 48rpx;
  508. .left{
  509. margin-right: 40rpx;
  510. .row1{
  511. .name{
  512. font-size: 38rpx;
  513. font-weight: bold;
  514. color: #040000;
  515. margin-right: 20rpx;
  516. }
  517. .post{
  518. font-size: 26rpx;
  519. font-weight: 500;
  520. color: #666666;
  521. }
  522. }
  523. .row2{
  524. margin-top: 20rpx;
  525. font-size: 24rpx;
  526. font-weight: bold;
  527. color: #323333;
  528. }
  529. }
  530. .right{
  531. .row1,.row2{
  532. font-size: 24rpx;
  533. font-weight: 500;
  534. color: #323333;
  535. }
  536. .row2{
  537. margin-top: 20rpx;
  538. }
  539. }
  540. }
  541. }
  542. }
  543. </style>