cardHolder.vue 17 KB

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