cardHolder.vue 19 KB

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