cardHolder.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. <template>
  2. <view class="content">
  3. <u-navbar title="电子名片" placeholder>
  4. <view class="u-nav-slot relative" slot="left">
  5. <u-icon name="bell" size="26" @click="toNotice"></u-icon>
  6. <u-badge :isDot="unread>0?true:false" type="error" class="point"></u-badge>
  7. </view>
  8. </u-navbar>
  9. <view class="content1 flex-row-center">
  10. <view class="col flex">
  11. <uni-icons type="scan" size="30" @click="scan"></uni-icons>
  12. </view>
  13. <view class="search flex flex-between" @click="search">
  14. <view class="left flex">
  15. <uni-icons type="search" size="24"></uni-icons>
  16. <text class="search-val"> {{searchVal?searchVal:'搜索名片'}}</text>
  17. <uni-icons type="closeempty" size="24" @click.native.stop="delSearchVal"
  18. v-if="searchVal"></uni-icons>
  19. </view>
  20. <view class="right">
  21. <uni-icons type="mic" size="24" @click.native.stop="micOpen"></uni-icons>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="content2">
  26. <view class="all-type flex" @click="selectType">
  27. <text>{{typeName?typeName:'全部分类'}}</text>
  28. <uni-icons type="bottom" size="20"></uni-icons>
  29. </view>
  30. </view>
  31. <!-- <u-skeleton
  32. :animate="true"
  33. rows="3"
  34. title
  35. :loading='loading'
  36. ></u-skeleton> -->
  37. <view v-if='islongPress'>
  38. <view @click="del">删除</view>
  39. <view @click='islongPress=false'>取消</view>
  40. <u-checkbox-group placement="column" @change="checkboxChange($event,'')">
  41. <u-checkbox :checked='checked' name='全部' :customStyle="{marginBottom: '8px'}">
  42. </u-checkbox>
  43. </u-checkbox-group>
  44. </view>
  45. <mescroll-body v-if='cardHolderList' :up="upOption" ref="mescrollRef" @init="mescrollInit" @up="upCallback"
  46. @down="downCallback">
  47. <view v-for='(item,index) in cardHolderList' @longpress="longpress" class="content3 flex">
  48. <view class="left">
  49. <view class="top flex-row-center">
  50. <image :src="item.headSculpture" mode="widthFix" class="img"></image>
  51. </view>
  52. <view class="bottom flex flex-evenly">
  53. <uni-icons @click="toHome(item)" type="home" size="20"></uni-icons>
  54. <text @click='switchType(item)'>{{item.classify?item.classifyName:'默'}}</text>
  55. <uni-icons @click='share(item)' type="redo" size="20" color=''></uni-icons>
  56. </view>
  57. </view>
  58. <view class="right">
  59. <view class="row1 flex">
  60. <text>{{item.name}}</text>
  61. <text class="line"></text>
  62. <text>{{item.post}}</text>
  63. <u-checkbox-group v-if='islongPress' placement="column" @change="checkboxChange($event,index)">
  64. <u-checkbox :name='index+1' :checked='item.checked' :customStyle="{marginBottom: '8px'}">
  65. </u-checkbox>
  66. </u-checkbox-group>
  67. </view>
  68. <view class="row2">
  69. {{item.companyName}}
  70. </view>
  71. <view class="row3" @click="toMap(item)">
  72. <uni-icons type="redo" size="20"></uni-icons>
  73. <text>{{item.province}}{{item.city}}{{item.area}}{{item.detailedAddress}}</text>
  74. </view>
  75. <view class="row3">
  76. <uni-icons type="redo" size="20"></uni-icons>
  77. <text>{{item.phone}}</text>
  78. </view>
  79. <view @click='remarkEdit(item)' class="row3">
  80. <uni-icons type="redo" size="20"></uni-icons>
  81. <text>{{item.remark?item.remark:'单击添加备注'}}</text>
  82. </view>
  83. </view>
  84. </view>
  85. </mescroll-body>
  86. <u-picker :show="isShowType" :columns="typeColumns" keyName="circleName" title="选择分类" @close="isShowType=false"
  87. @cancel="isShowType=false" closeOnClickOverlay @confirm="typeConfirm"></u-picker>
  88. <u-toast ref="uToast"></u-toast>
  89. <u-modal :show="delShow" title="提示" showCancelButton='true' @cancel="delShow=false" @confirm="delConfirm"
  90. :content='"已选中"+this.checkedList.length+"张名片,确定删除?"'></u-modal>
  91. <u-modal :show="modalShow" @confirm='remarkConfirm' :confirmColor="remark?'#2979ff':'#ccc'"
  92. showCancelButton='true' title="备注">
  93. <view class="slot-content">
  94. <u--textarea v-model="remark" placeholder="输入备注,不超过150个字"></u--textarea>
  95. </view>
  96. </u-modal>
  97. <view v-if='qrcodeShow' class="shade">
  98. <view class='qrCode'>
  99. <view style='text-align:right;'>
  100. <uni-icons @click='qrcodeShow=false' type="close" size="20"></uni-icons>
  101. </view>
  102. <image :src="currectData.qrCode" mode=""></image>
  103. </view>
  104. </view>
  105. <u-popup :show="popupshow" mode="bottom">
  106. <view>
  107. <view class="share-to">
  108. <text>分享到</text>
  109. </view>
  110. <view class="content">
  111. <view class="block" @click="toUrl()">
  112. <button class="moment">
  113. <text class="iconfont icon-weixin"></text>
  114. <!-- <image src="/static/img/moment.png" mode="aspectFill"></image> -->
  115. <text>扫码分享</text>
  116. </button>
  117. </view>
  118. <view class="block">
  119. <button class="shareBtn" type="default" data-name="shareBtn" open-type="share"> 分享</button>
  120. </view>
  121. </view>
  122. <view class="cancel" @click.stop="handleHiddenShare">
  123. <text>取消</text>
  124. </view>
  125. </view>
  126. </u-popup>
  127. <!-- <image :src="poster" style="width: 750rpx;height: 1334rpx;"></image> -->
  128. <!-- 生成图片 -->
  129. <poster :list="canvasData" background-color="#FFF"
  130. @on-success="posterSuccess" ref="poster" @on-error="posterError"></poster>
  131. </view>
  132. </template>
  133. <script>
  134. import Poster from '../../components/zhangyuhao-poster/Poster.vue'
  135. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  136. export default {
  137. mixins: [MescrollMixin],
  138. components: {
  139. Poster
  140. },
  141. data() {
  142. return {
  143. poster: '',
  144. canvasData: [],
  145. searchVal: '',
  146. isShowType: false,
  147. loading: true,
  148. typeName: '',
  149. typeColumns: [],
  150. cardHolderList: [],
  151. currectData: [],
  152. type: 1,
  153. popupshow: false,
  154. modalShow: false,
  155. remark: '',
  156. islongPress: false,
  157. checked: false,
  158. checkedList: [],
  159. delShow: false,
  160. qrcodeShow: false,
  161. unread: 0,
  162. noticeList: [],
  163. };
  164. },
  165. onShow() {
  166. if (uni.getStorageSync("userInfo")) {
  167. this.userInfo = uni.getStorageSync("userInfo")
  168. this.init()
  169. } else {
  170. this.login()
  171. }
  172. this.searchVal = uni.getStorageSync("search_val") ? uni.getStorageSync("search_val") : ''
  173. },
  174. mounted() {
  175. },
  176. onLoad: function() {
  177. wx.showShareMenu({
  178. withShareTicket: true,
  179. menus: ["shareAppMessage", "shareTimeline"]
  180. })
  181. },
  182. onShareAppMessage(res) {
  183. console.log(1111)
  184. let that = this;
  185. //生成名片图片
  186. let imageUrl = this.poster
  187. console.log("imageUrl",imageUrl)
  188. if (res.from === 'button') {
  189. let path = `/pages/cardHolder/scanCodeAddCard?id=${that.currectData.id}`
  190. return {
  191. title: `${that.currectData.name}分享的名片~`,
  192. path: path,
  193. imageUrl: imageUrl,
  194. };
  195. }
  196. if (res.from === 'menu') {
  197. return {
  198. title: '商通线上商城',
  199. path: '/pages/tabBarPro/index/index',
  200. imageUrl: imageUrl
  201. };
  202. }
  203. },
  204. // 分享到朋友圈
  205. onShareTimeline() {
  206. return {
  207. title: '商通线上商城',
  208. path: '/pages/index/index',
  209. imageUrl: 'https://cdn.uviewui.com/uview/swiper/1.jpg'
  210. };
  211. },
  212. methods: {
  213. posterError(err) {
  214. console.log(err)
  215. },
  216. posterSuccess(url) {
  217. console.log("hahahah",url)
  218. // 生成成功,会把临时路径在这里返回
  219. this.poster = url;
  220. console.log(url)
  221. },
  222. toHome(item) {
  223. uni.navigateTo({
  224. url: "/pages/mySet/myHome?id=" + item.personalHomeId
  225. })
  226. },
  227. delSearchVal() {
  228. this.searchVal = ""
  229. this.mescroll.resetUpScroll()
  230. },
  231. toUrl() {
  232. console.log(this.currectData)
  233. this.popupshow = false
  234. this.qrcodeShow = true
  235. },
  236. share(item) {debugger
  237. this.currectData = item
  238. this.canvasData = [{
  239. type: 'image',
  240. path: item.currentBackground,
  241. x: 0,
  242. y: 0,
  243. width: 750,
  244. height: 424
  245. },
  246. // {
  247. // type: 'text',
  248. // text:item.name,
  249. // x: 0,
  250. // y: 0,
  251. // size:13
  252. // },
  253. ]
  254. // this.popupshow = true
  255. },
  256. async delConfirm() {
  257. uni.showLoading({
  258. title: '数据加载中',
  259. mask: true
  260. })
  261. for (var i = 0; i < this.checkedList.length; i++) {
  262. await this.$request.baseRequest('admin.unimall.cardHolderInfo', 'delete', {
  263. id: this.checkedList[i].data.id,
  264. }, failres => {
  265. console.log('res+++++', failres.errmsg)
  266. this.$refs.uToast.show({
  267. type: 'error',
  268. message: failres.errmsg,
  269. })
  270. }).then(res => {
  271. console.log(i, this.checkedList.length - 1)
  272. if (i == this.checkedList.length - 1) {
  273. uni.hideLoading()
  274. this.$refs.uToast.show({
  275. type: 'success',
  276. message: '删除成功',
  277. })
  278. this.delShow = false
  279. this.islongPress = false
  280. this.mescroll.resetUpScroll()
  281. }
  282. })
  283. }
  284. },
  285. del() {
  286. this.delShow = true
  287. },
  288. longpress() {
  289. console.log("长按事件", 1111111111);
  290. this.islongPress = true;
  291. },
  292. checkboxChange(e, i) {
  293. console.log(e, i, 111111111)
  294. if (i === '') {
  295. console.log(this.checked)
  296. this.checked = !this.checked;
  297. this.cardHolderList.map(item => item.checked = this.checked);
  298. this.$forceUpdate()
  299. var checkList = this.cardHolderList.filter((item) => {
  300. return item.checked == true
  301. })
  302. var data = checkList.map((item, index) => {
  303. return {
  304. index: index,
  305. data: item
  306. }
  307. })
  308. this.checkedList = JSON.parse(JSON.stringify(data))
  309. } else {
  310. if (e[0]) {
  311. this.checkedList.push({
  312. index: i,
  313. data: this.cardHolderList[i]
  314. })
  315. } else {
  316. var index = this.checkedList.findIndex((item) => {
  317. return item.index == i
  318. })
  319. this.checkedList.splice(index, 1)
  320. }
  321. if (this.checkedList.length != this.cardHolderList.length) {
  322. this.checked = false
  323. }
  324. }
  325. // for(var i=0;i<this.cardList.length;i++){
  326. // console.log(this.cardList[i].checked)
  327. // // if(this.cardList[i].checkedList.length>0){
  328. // // this.checkedList.push(i)
  329. // // }
  330. // }
  331. console.log(this.checkedList)
  332. },
  333. remarkConfirm() {
  334. if (this.remark) {
  335. this.currectData.remark = this.remark
  336. this.$request.baseRequest('admin.unimall.cardHolderInfo', 'update', {
  337. cardHolderInfo: JSON.stringify(this.currectData),
  338. }, failres => {
  339. console.log('res+++++', failres.errmsg)
  340. this.$refs.uToast.show({
  341. type: 'error',
  342. message: failres.errmsg,
  343. })
  344. }).then(res => {
  345. this.$refs.uToast.show({
  346. type: 'success',
  347. message: '修改备注成功',
  348. })
  349. this.modalShow = false
  350. this.mescroll.resetUpScroll()
  351. })
  352. }
  353. },
  354. remarkEdit(item) {
  355. this.currectData = item
  356. this.modalShow = true
  357. },
  358. switchType(item) {
  359. this.type = 2
  360. this.currectData = item
  361. this.isShowType = true
  362. },
  363. typeConfirm(e) {
  364. if (this.type == 2) {
  365. this.currectData.classify = e.value[0].circleName
  366. this.$request.baseRequest('admin.unimall.cardHolderInfo', 'update', {
  367. cardHolderInfo: JSON.stringify(this.currectData),
  368. }, failres => {
  369. console.log('res+++++', failres.errmsg)
  370. this.$refs.uToast.show({
  371. type: 'error',
  372. message: failres.errmsg,
  373. })
  374. }).then(res => {
  375. this.$refs.uToast.show({
  376. type: 'success',
  377. message: '修改分类成功',
  378. })
  379. this.mescroll.resetUpScroll()
  380. })
  381. } else {
  382. this.typeName = e.value[0].circleName
  383. }
  384. this.isShowType = false
  385. },
  386. init() {
  387. this.getList()
  388. this.$request.baseRequest('admin.unimall.cardClassifyInfo', 'list', {
  389. page: 1,
  390. limit: 9999,
  391. commonId: uni.getStorageSync("userInfo").id
  392. }, failres => {
  393. console.log('res+++++', failres.errmsg)
  394. this.$refs.uToast.show({
  395. type: 'error',
  396. message: failres.errmsg,
  397. })
  398. }).then(res => {
  399. this.typeColumns = [res.data.items]
  400. this.mescroll.resetUpScroll()
  401. console.log(this.typeColumns)
  402. })
  403. },
  404. getList() {
  405. this.$request.baseRequest('admin.unimall.cardNewsInfo', 'list', {
  406. receiveId: uni.getStorageSync("userInfo").id,
  407. }, failres => {
  408. console.log('res+++++', failres.errmsg)
  409. this.$refs.uToast.show({
  410. type: 'error',
  411. message: failres.errmsg,
  412. })
  413. }).then(res => {
  414. this.noticeList = res.data.items
  415. if (this.noticeList.length > 0) {
  416. var data = this.noticeList.filter((item) => {
  417. return item.newsFlag == 0
  418. })
  419. this.unread = data ? data.length : 0
  420. }
  421. console.log(this.unread)
  422. })
  423. },
  424. upCallback(page) {
  425. var that = this
  426. uni.showLoading({
  427. title: '数据加载中'
  428. })
  429. this.$request.baseRequest('admin.unimall.cardHolderInfo', 'list', {
  430. page: page.num,
  431. limit: page.size,
  432. commonId: uni.getStorageSync("userInfo").id,
  433. searchContent: this.searchVal
  434. }, failres => {
  435. console.log('res+++++', failres.errmsg)
  436. this.$refs.uToast.show({
  437. type: 'error',
  438. message: failres.errmsg,
  439. })
  440. uni.hideLoading()
  441. }).then(res => {
  442. console.log(res)
  443. if (page.num == 1) this.cardHolderList = [];
  444. let curPageLen = res.data.items.length;
  445. let totalPage = res.data.total;
  446. for (var i = 0; i < res.data.items.length; i++) {
  447. res.data.items[i].checked = false
  448. if (res.data.items[i].classify) {
  449. res.data.items[i].classifyName = res.data.items[i].classify[0]
  450. }
  451. }
  452. this.cardHolderList = res.data.items
  453. this.loading = false
  454. // if(res.data.items.length>0){
  455. // for(var i=0;i<res.data.items.length;i++){
  456. // res.data.items[i].name=res.data.items[i].circleName[0]
  457. // }
  458. // var itemIndex=res.data.items.findIndex((item)=>{return item.topMarking==1})
  459. // if(itemIndex!=-1){
  460. // var data=res.data.items.splice(itemIndex,1)
  461. // if(page.num==1){
  462. // data.push({circleName:'默认分类',name:'默'})
  463. // }
  464. // res.data.items=data.concat(res.data.items)
  465. // }else{
  466. // if(page.num==1){
  467. // res.data.items=[{circleName:'默认分类',name:'默'}].concat(res.data.items)
  468. // }
  469. // }
  470. // this.cardTypeList=this.cardTypeList.concat(res.data.items)
  471. // }else{
  472. // if(page.num==1){
  473. // this.cardTypeList=[{circleName:'默认分类',name:'默'}]
  474. // }
  475. // }
  476. this.$nextTick(() => {
  477. console.log(that)
  478. // mescroll.endSuccess(data.result);
  479. that.mescroll.endBySize(curPageLen, totalPage)
  480. });
  481. // if (res.errno == 200) {
  482. uni.hideLoading()
  483. // }
  484. })
  485. },
  486. login() {
  487. let that = this
  488. uni.login({
  489. "provider": "weixin",
  490. success: function(wxres) {
  491. that.$request.baseRequest('commonUserApp', 'commonUserLogin', {
  492. loginType: 1,
  493. raw: JSON.stringify(wxres)
  494. }, failres => {
  495. this.$refs.uToast.show({
  496. type: 'error',
  497. message: failres.errmsg,
  498. })
  499. uni.hideLoading()
  500. }).then(res => {
  501. uni.getUserInfo({
  502. provider: 'weixin',
  503. success: function(info) {
  504. console.log(info)
  505. res.data.nickname = info.userInfo.nickName
  506. res.data.head = info.userInfo.avatarUrl
  507. that.$request.baseRequest('commonUserApp', 'edit', {
  508. commonUserInfo: JSON.stringify(res.data)
  509. }, failres => {
  510. this.$refs.uToast.show({
  511. type: 'error',
  512. message: failres.errmsg,
  513. })
  514. uni.hideLoading()
  515. }).then(res1 => {
  516. uni.setStorageSync("userInfo", res1.data)
  517. })
  518. }
  519. })
  520. })
  521. },
  522. fail: function(err) {
  523. // 登录授权失败
  524. // err.code是错误码
  525. }
  526. })
  527. },
  528. toNotice() {
  529. uni.navigateTo({
  530. url: "/pages/cardHolder/notice"
  531. })
  532. },
  533. micOpen: function() {
  534. uni.navigateTo({
  535. url: "/pages/cardHolder/search?mic=1"
  536. })
  537. },
  538. uploadFile: function(tempFilePath) {
  539. return new Promise((resolve, reject) => {
  540. //调用你的接口把音频文件转为文字
  541. this.$minApi.upload('txasr/SentenceRecognition', null, tempFilePath)
  542. .then(res => {
  543. if (res.code == 1) {
  544. resolve(res.data.Result);
  545. } else {
  546. reject(e);
  547. }
  548. })
  549. .catch(e => {
  550. reject(e);
  551. });
  552. });
  553. },
  554. search() {
  555. uni.navigateTo({
  556. url: "/pages/cardHolder/search"
  557. })
  558. },
  559. input(res) {
  560. console.log('----input:', res)
  561. },
  562. clear(res) {
  563. uni.showToast({
  564. title: 'clear事件,清除值为:' + res.value,
  565. icon: 'none'
  566. })
  567. },
  568. blur(res) {
  569. uni.showToast({
  570. title: 'blur事件,输入值为:' + res.value,
  571. icon: 'none'
  572. })
  573. },
  574. focus(e) {
  575. uni.showToast({
  576. title: 'focus事件,输出值为:' + e.value,
  577. icon: 'none'
  578. })
  579. },
  580. cancel(res) {
  581. uni.showToast({
  582. title: '点击取消,输入值为:' + res.value,
  583. icon: 'none'
  584. })
  585. },
  586. selectType() {
  587. this.isShowType = true
  588. this.type = 1
  589. },
  590. scan() {
  591. // console.log(1)
  592. // uni.navigateTo({
  593. // url: "/pages/cardHolder/scancode"
  594. // })
  595. uni.scanCode({
  596. success: function(res) {
  597. console.log('条码类型:' + res.scanType);
  598. console.log('条码内容:' + res.result);
  599. uni.navigateTo({
  600. url: "/pages/cardHolder/scanCodeAddCard?id=" + res.result
  601. })
  602. }
  603. });
  604. },
  605. toMap(item) {
  606. uni.navigateTo({
  607. url: "/pages/cardHolder/map?location=" + item.location
  608. })
  609. },
  610. }
  611. }
  612. </script>
  613. <style lang="scss" scoped>
  614. .content {
  615. padding: 0 20rpx;
  616. }
  617. .u-nav-slot {
  618. /deep/.u-badge {
  619. position: absolute;
  620. top: 0;
  621. right: 6rpx;
  622. }
  623. }
  624. .content1 {
  625. margin-top: 20rpx;
  626. .search {
  627. margin-left: 20rpx;
  628. border: 1px solid #ccc;
  629. border-radius: 50rpx;
  630. width: 100%;
  631. padding: 10rpx 30rpx;
  632. box-sizing: border-box;
  633. .left {
  634. .search-val {
  635. margin-left: 30rpx;
  636. }
  637. }
  638. }
  639. }
  640. .content2 {
  641. .all-type {}
  642. }
  643. .content3 {
  644. border: 1px solid #ccc;
  645. border-radius: 30rpx;
  646. padding: 40rpx;
  647. box-sizing: border-box;
  648. .left {
  649. width: 30%;
  650. .top {
  651. margin-bottom: 20rpx;
  652. }
  653. .img {
  654. width: 80%;
  655. }
  656. .bottom {}
  657. }
  658. .right {
  659. .row1 {
  660. .line {
  661. width: 1px;
  662. height: 20px;
  663. margin: 0 20rpx;
  664. background: black;
  665. }
  666. }
  667. }
  668. }
  669. .slot-content {
  670. width: 100%;
  671. }
  672. .shade {
  673. background: rgba(0, 0, 0, 0.2);
  674. width: 100%;
  675. height: 100vh;
  676. position: fixed;
  677. top: 0;
  678. left: 0;
  679. }
  680. .qrCode {
  681. position: absolute;
  682. top: 50%;
  683. left: 0;
  684. right: 0;
  685. transform: translateY(-50%);
  686. text-align: center;
  687. }
  688. </style>