cardHolder.vue 16 KB

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