cardHolder.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  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. <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">
  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. };
  158. },
  159. onShow() {
  160. if (uni.getStorageSync("userInfo")) {
  161. this.userInfo = uni.getStorageSync("userInfo")
  162. this.init()
  163. } else {
  164. this.login()
  165. }
  166. this.searchVal = uni.getStorageSync("search_val") ? uni.getStorageSync("search_val") : ''
  167. },
  168. onShareAppMessage(res) {
  169. debugger
  170. let that = this;
  171. let imageUrl = that.shareUrl || '';
  172. if (res.from === 'button') {
  173. //这块需要传参,不然链接地址进去获取不到数据
  174. let path = `/` + that.$scope.route + `?item=` + that.$scope.options.item;
  175. return {
  176. title: '名片夹',
  177. path: path,
  178. imageUrl: imageUrl
  179. };
  180. }
  181. // if (res.from === 'menu') {
  182. // return {
  183. // title: '商通线上商城',
  184. // path: '/pages/tabBarPro/index/index',
  185. // imageUrl: imageUrl
  186. // };
  187. // }
  188. },
  189. methods: {
  190. toHome(item){
  191. uni.navigateTo({
  192. url: "/pages/mySet/myHome?id="+item.personalHomeId
  193. })
  194. },
  195. delSearchVal() {
  196. this.searchVal = ""
  197. this.mescroll.resetUpScroll()
  198. },
  199. toUrl(){
  200. console.log(this.currectData)
  201. this.popupshow=false
  202. this.qrcodeShow=true
  203. },
  204. share(item){
  205. this.currectData=item
  206. this.popupshow=true
  207. },
  208. async delConfirm(){
  209. uni.showLoading({
  210. title: '数据加载中',
  211. mask:true
  212. })
  213. for(var i=0;i<this.checkedList.length;i++){
  214. await this.$request.baseRequest('admin.unimall.cardHolderInfo', 'delete',{
  215. id:this.checkedList[i].data.id,
  216. }, failres => {
  217. console.log('res+++++', failres.errmsg)
  218. this.$refs.uToast.show({
  219. type: 'error',
  220. message: failres.errmsg,
  221. })
  222. }).then(res => {
  223. console.log(i,this.checkedList.length-1)
  224. if(i==this.checkedList.length-1){
  225. uni.hideLoading()
  226. this.$refs.uToast.show({
  227. type: 'success',
  228. message: '删除成功',
  229. })
  230. this.delShow=false
  231. this.islongPress=false
  232. this.mescroll.resetUpScroll()
  233. }
  234. })
  235. }
  236. },
  237. del(){
  238. this.delShow=true
  239. },
  240. longpress(){
  241. console.log("长按事件",1111111111);
  242. this.islongPress = true;
  243. },
  244. checkboxChange(e, i) {
  245. console.log(e,i,111111111)
  246. if(i===''){
  247. console.log(this.checked)
  248. this.checked = !this.checked;
  249. this.cardHolderList.map(item => item.checked = this.checked);
  250. this.$forceUpdate()
  251. var checkList = this.cardHolderList.filter((item) => {
  252. return item.checked == true
  253. })
  254. var data=checkList.map((item,index) => {return {index:index,data:item}})
  255. this.checkedList = JSON.parse(JSON.stringify(data))
  256. }else{
  257. if (e[0]) {
  258. this.checkedList.push({index:i,data:this.cardHolderList[i]})
  259. } else {
  260. var index = this.checkedList.findIndex((item) => {
  261. return item.index == i
  262. })
  263. this.checkedList.splice(index, 1)
  264. }
  265. if(this.checkedList.length!=this.cardHolderList.length){
  266. this.checked=false
  267. }
  268. }
  269. // for(var i=0;i<this.cardList.length;i++){
  270. // console.log(this.cardList[i].checked)
  271. // // if(this.cardList[i].checkedList.length>0){
  272. // // this.checkedList.push(i)
  273. // // }
  274. // }
  275. console.log(this.checkedList)
  276. },
  277. remarkConfirm(){
  278. if(this.remark){
  279. this.currectData.remark=this.remark
  280. this.$request.baseRequest('admin.unimall.cardHolderInfo', 'update',{
  281. cardHolderInfo:JSON.stringify(this.currectData),
  282. }, failres => {
  283. console.log('res+++++', failres.errmsg)
  284. this.$refs.uToast.show({
  285. type: 'error',
  286. message: failres.errmsg,
  287. })
  288. }).then(res => {
  289. this.$refs.uToast.show({
  290. type: 'success',
  291. message: '修改备注成功',
  292. })
  293. this.modalShow=false
  294. this.mescroll.resetUpScroll()
  295. })
  296. }
  297. },
  298. remarkEdit(item){
  299. this.currectData=item
  300. this.modalShow=true
  301. },
  302. switchType(item){
  303. this.type=2
  304. this.currectData=item
  305. this.isShowType=true
  306. },
  307. typeConfirm(e){
  308. if(this.type==2){
  309. this.currectData.classify=e.value[0].circleName
  310. this.$request.baseRequest('admin.unimall.cardHolderInfo', 'update',{
  311. cardHolderInfo:JSON.stringify(this.currectData),
  312. }, failres => {
  313. console.log('res+++++', failres.errmsg)
  314. this.$refs.uToast.show({
  315. type: 'error',
  316. message: failres.errmsg,
  317. })
  318. }).then(res => {
  319. this.$refs.uToast.show({
  320. type: 'success',
  321. message: '修改分类成功',
  322. })
  323. this.mescroll.resetUpScroll()
  324. })
  325. }else{
  326. this.typeName = e.value[0].circleName
  327. }
  328. this.isShowType = false
  329. },
  330. init(){
  331. this.$request.baseRequest('admin.unimall.cardClassifyInfo', 'list',{
  332. page:1,
  333. limit:9999,
  334. commonId:uni.getStorageSync("userInfo").id
  335. }, failres => {
  336. console.log('res+++++', failres.errmsg)
  337. this.$refs.uToast.show({
  338. type: 'error',
  339. message: failres.errmsg,
  340. })
  341. }).then(res => {
  342. this.typeColumns=[res.data.items]
  343. this.mescroll.resetUpScroll()
  344. console.log(this.typeColumns)
  345. })
  346. },
  347. upCallback(page){
  348. var that = this
  349. uni.showLoading({
  350. title: '数据加载中'
  351. })
  352. this.$request.baseRequest('admin.unimall.cardHolderInfo', 'list',{
  353. page:page.num,
  354. limit:page.size,
  355. commonId:uni.getStorageSync("userInfo").id,
  356. searchContent:this.searchVal
  357. }, failres => {
  358. console.log('res+++++', failres.errmsg)
  359. this.$refs.uToast.show({
  360. type: 'error',
  361. message: failres.errmsg,
  362. })
  363. uni.hideLoading()
  364. }).then(res => {
  365. console.log(res)
  366. if(page.num == 1) this.cardHolderList = [];
  367. let curPageLen = res.data.items.length;
  368. let totalPage = res.data.total;
  369. for (var i = 0; i < res.data.items.length; i++) {
  370. res.data.items[i].checked=false
  371. if(res.data.items[i].classify){
  372. res.data.items[i].classifyName=res.data.items[i].classify[0]
  373. }
  374. }
  375. this.cardHolderList=res.data.items
  376. this.loading=false
  377. // if(res.data.items.length>0){
  378. // for(var i=0;i<res.data.items.length;i++){
  379. // res.data.items[i].name=res.data.items[i].circleName[0]
  380. // }
  381. // var itemIndex=res.data.items.findIndex((item)=>{return item.topMarking==1})
  382. // if(itemIndex!=-1){
  383. // var data=res.data.items.splice(itemIndex,1)
  384. // if(page.num==1){
  385. // data.push({circleName:'默认分类',name:'默'})
  386. // }
  387. // res.data.items=data.concat(res.data.items)
  388. // }else{
  389. // if(page.num==1){
  390. // res.data.items=[{circleName:'默认分类',name:'默'}].concat(res.data.items)
  391. // }
  392. // }
  393. // this.cardTypeList=this.cardTypeList.concat(res.data.items)
  394. // }else{
  395. // if(page.num==1){
  396. // this.cardTypeList=[{circleName:'默认分类',name:'默'}]
  397. // }
  398. // }
  399. this.$nextTick(() => {
  400. console.log(that)
  401. // mescroll.endSuccess(data.result);
  402. that.mescroll.endBySize(curPageLen, totalPage)
  403. });
  404. // if (res.errno == 200) {
  405. uni.hideLoading()
  406. // }
  407. })
  408. },
  409. login() {
  410. let that = this
  411. uni.login({
  412. "provider": "weixin",
  413. success: function(wxres) {
  414. that.$request.baseRequest('commonUserApp', 'commonUserLogin', {
  415. loginType: 1,
  416. raw: JSON.stringify(wxres)
  417. }, failres => {
  418. this.$refs.uToast.show({
  419. type: 'error',
  420. message: failres.errmsg,
  421. })
  422. uni.hideLoading()
  423. }).then(res => {
  424. uni.getUserInfo({
  425. provider: 'weixin',
  426. success: function(info) {
  427. console.log(info)
  428. res.data.nickname = info.userInfo.nickName
  429. res.data.head = info.userInfo.avatarUrl
  430. that.$request.baseRequest('commonUserApp', 'edit', {
  431. commonUserInfo: JSON.stringify(res.data)
  432. }, failres => {
  433. this.$refs.uToast.show({
  434. type: 'error',
  435. message: failres.errmsg,
  436. })
  437. uni.hideLoading()
  438. }).then(res1 => {
  439. uni.setStorageSync("userInfo",res1.data)
  440. })
  441. }
  442. })
  443. })
  444. },
  445. fail: function(err) {
  446. // 登录授权失败
  447. // err.code是错误码
  448. }
  449. })
  450. },
  451. toNotice() {
  452. uni.navigateTo({
  453. url: "/pages/cardHolder/notice"
  454. })
  455. },
  456. micOpen: function() {
  457. this.$refs.asr.show();
  458. },
  459. asrChange: function(res) {
  460. console.log('语音识别确认结果:' + res);
  461. },
  462. fileChange: function({
  463. file,
  464. content
  465. }) {
  466. console.log('录音文件', file);
  467. },
  468. uploadFile: function(tempFilePath) {
  469. return new Promise((resolve, reject) => {
  470. //调用你的接口把音频文件转为文字
  471. this.$minApi.upload('txasr/SentenceRecognition', null, tempFilePath)
  472. .then(res => {
  473. if (res.code == 1) {
  474. resolve(res.data.Result);
  475. } else {
  476. reject(e);
  477. }
  478. })
  479. .catch(e => {
  480. reject(e);
  481. });
  482. });
  483. },
  484. search() {
  485. uni.navigateTo({
  486. url: "/pages/cardHolder/search"
  487. })
  488. },
  489. input(res) {
  490. console.log('----input:', res)
  491. },
  492. clear(res) {
  493. uni.showToast({
  494. title: 'clear事件,清除值为:' + res.value,
  495. icon: 'none'
  496. })
  497. },
  498. blur(res) {
  499. uni.showToast({
  500. title: 'blur事件,输入值为:' + res.value,
  501. icon: 'none'
  502. })
  503. },
  504. focus(e) {
  505. uni.showToast({
  506. title: 'focus事件,输出值为:' + e.value,
  507. icon: 'none'
  508. })
  509. },
  510. cancel(res) {
  511. uni.showToast({
  512. title: '点击取消,输入值为:' + res.value,
  513. icon: 'none'
  514. })
  515. },
  516. selectType() {
  517. this.isShowType = true
  518. this.type=1
  519. },
  520. scan() {
  521. // console.log(1)
  522. uni.navigateTo({
  523. url: "/pages/cardHolder/scancode"
  524. })
  525. // uni.scanCode({
  526. // success: function(res) {
  527. // console.log('条码类型:' + res.scanType);
  528. // console.log('条码内容:' + res.result);
  529. // }
  530. // });
  531. },
  532. toMap() {
  533. uni.navigateTo({
  534. url: "/pages/cardHolder/map"
  535. })
  536. },
  537. }
  538. }
  539. </script>
  540. <style lang="scss" scoped>
  541. .content {
  542. padding: 0 20rpx;
  543. }
  544. .u-nav-slot {
  545. /deep/.u-badge {
  546. position: absolute;
  547. top: 0;
  548. right: 6rpx;
  549. }
  550. }
  551. .content1 {
  552. margin-top: 20rpx;
  553. .search {
  554. margin-left: 20rpx;
  555. border: 1px solid #ccc;
  556. border-radius: 50rpx;
  557. width: 100%;
  558. padding: 10rpx 30rpx;
  559. box-sizing: border-box;
  560. .left {
  561. .search-val {
  562. margin-left: 30rpx;
  563. }
  564. }
  565. }
  566. }
  567. .content2 {
  568. .all-type {
  569. }
  570. }
  571. .content3 {
  572. border: 1px solid #ccc;
  573. border-radius: 30rpx;
  574. padding: 40rpx;
  575. box-sizing: border-box;
  576. .left {
  577. width: 30%;
  578. .top {
  579. margin-bottom: 20rpx;
  580. }
  581. .img {
  582. width: 80%;
  583. }
  584. .bottom {
  585. }
  586. }
  587. .right {
  588. .row1 {
  589. .line {
  590. width: 1px;
  591. height: 20px;
  592. margin: 0 20rpx;
  593. background: black;
  594. }
  595. }
  596. }
  597. }
  598. .slot-content{
  599. width:100%;
  600. }
  601. .shade{
  602. background:rgba(0,0,0,0.2);
  603. width:100%;height:100vh;
  604. position:fixed;
  605. top:0;
  606. left:0;
  607. }
  608. .qrCode{
  609. position:absolute;
  610. top:50%;
  611. left:0;
  612. right:0;
  613. transform: translateY(-50%);
  614. text-align:center;
  615. }
  616. </style>