cardFound.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. <template>
  2. <view>
  3. <view class="map-box">
  4. <map class="map" id="map1" ref="map1" @regionchange="regionChange" :latitude="latitude" :longitude="longitude" :markers="covers" @markertap="clickMap" :scale="mapScale" :circles="circles"></map>
  5. <!-- <view class="store" @click="showStore"><image src="../../static/images/sj_map_ico.png"></image></view>
  6. <view class="ibn" @click="showCab"><image src="../../static/images/jg_map_ico.png"></image><view class="count ddflex">12</view></view> -->
  7. <view class="nearby-box ddflex">
  8. <view class="nearby-yuan"></view>
  9. <image src="../../static/images/fj_loca.png" class="loca"></image>
  10. <view class="nearby">
  11. <view class="nearby-text ddflex" @click="jumpUrl('/card/cardList/cardList')">附近<image src="/static/pages/images/more.png"></image></view>
  12. <view class="gan"></view>
  13. </view>
  14. </view>
  15. <view class="side">
  16. <view class="li ddflex" @click="getLoca"><image src="../../static/images/side_ico3.png"></image></view>
  17. </view>
  18. </view>
  19. <view class="cabinet" :style="'bottom:' + cabBottom">
  20. <view class="register-box">
  21. <view class="register-title ddflex fflex" @click.stop="jumpUrl('/card/cardDetail/cardDetail?id='+cabInfo.id)">
  22. <image class="register-title-icon" :src="cabInfo.avatar?cabInfo.avatar:'/static/images/userimg.png'"></image>
  23. <view class="flex" style="min-width: 0;">
  24. <view class="ddflex">
  25. <view class="card-name fflex tover">{{cabInfo.realName?cabInfo.realName:''}}</view>
  26. <uni-rate class="ddflex" color="#999999" active-color="#FF4600" :readonly="true" size="16" allow-half :value="cabInfo.evaluateScore?cabInfo.evaluateScore/2:5" />
  27. </view>
  28. <view class="ddflex" style="margin-top: 4rpx;">
  29. <view class="card-tag">{{cabInfo.jobName}}</view>
  30. <view class="card-tag">入司{{cabInfo.inDate?getAge(cabInfo.inDate):1}}年</view>
  31. </view>
  32. <view class="card-area ddflex">
  33. <image src="/static/pages/images/dzico.png"></image>
  34. <view class="flex tover">{{cabInfo.address}}</view>
  35. <view style="color: #A1A1A1;margin-left: 10rpx;">距离{{cabInfo.distance>1000?((cabInfo.distance/1000).toFixed(2)+'km'):(cabInfo.distance+'m')}}</view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <!-- @click="jumpUrl('/card/cardList/cardList')" -->
  41. <view class="found-more ddflex" @click="jumpUrl('/card/cardList/cardList')">
  42. <image src="../../static/images/found_more.png"></image>
  43. 寻找更多保险顾问
  44. </view>
  45. </view>
  46. <canvas v-if="canvasShow" class="canvas" style="width:80px;height:92px;" canvas-id="logoIcon"></canvas>
  47. <!-- <update-userinfo :update-info="isUpdateInfo" :update-mobile="isUpdateMobile" v-if="isShowUpdate" @closeUpdate="closeUpdate" @updateInfo="updateInfo" @updateMobile="updateMobile"></update-userinfo> -->
  48. </view>
  49. </template>
  50. <script>
  51. const app = getApp();
  52. const req = require('../../utils/request.js');
  53. const api = require('../../utils/api.js');
  54. const util = require('../../utils/util.js');
  55. const QQMapWX = require("../../utils/qqmap.js");
  56. export default {
  57. data() {
  58. return {
  59. picUrlss: req.public.picUrls,
  60. userInfo: {},
  61. map: '',
  62. latitude: '23.027923',
  63. longitude: '113.753815',
  64. mapScale: 16,
  65. circles: [],
  66. covers: [],
  67. cabList: [],//机柜列表
  68. cabInfo: {},//机柜详情
  69. cabBottom: '-100%',
  70. storeList: [],//门店列表
  71. storeInfo: {},//门店详情
  72. storeBottom: '-100%',
  73. isAuth: false,//是否实名认证
  74. markerId: '',
  75. orderCount: '',//订单数
  76. isShowUpdate: false,//是否显示更新信息弹窗
  77. // isUpdateInfo: false,//更新用户信息
  78. isUpdateMobile: false,//绑定手机号
  79. realInfo: {},//实名认证信息
  80. config: {},//配置信息
  81. popadv: '',//弹窗广告
  82. topadv: '',//顶部广告
  83. isShowPopAdv: false,
  84. isShowTopAdv: false,
  85. canvasShow:false
  86. }
  87. },
  88. async onLoad(options) {
  89. if(options.userId){
  90. req.setStorage('pidCode',options.userId);
  91. }
  92. // req.silenceLogin(options.userId, '');
  93. this.map = uni.createMapContext("map1", this);
  94. let locations = req.getStorage('loctionAddressMap');
  95. QQMapWX.initMap();
  96. req.getLocation(res => {
  97. const to = {
  98. latitude: res.latitude,
  99. longitude: res.longitude
  100. };
  101. req.setStorage('loctionAddressMap',to)
  102. this.latitude = res.latitude;
  103. this.longitude = res.longitude;
  104. this.map.moveToLocation(to,res=>{})
  105. QQMapWX.reverseGeocoder(to,async resp => {
  106. await this.getCabList();
  107. });
  108. });
  109. },
  110. onShow() {
  111. this.getConfig();
  112. // this.userInfo.authState = 1;
  113. },
  114. onHide() {
  115. this.hideStore();
  116. this.hideCab();
  117. },
  118. methods: {
  119. hidePopAdv(){
  120. this.isShowPopAdv = false;
  121. },
  122. hideTopAdv(){
  123. this.isShowTopAdv = false;
  124. },
  125. banJump(item){
  126. app.globalData.clickBanner(item)
  127. },
  128. getConfig(){
  129. req.getRequest('/api/other/config',{},data=>{
  130. req.setStorage('configRes',JSON.stringify(data));
  131. this.config = data;
  132. })
  133. },
  134. addNearby(){
  135. let cover = [];
  136. let obj = {
  137. column: 0,
  138. type: 2,
  139. latitude: req.getStorage('loctionAddressMap').location.lat,
  140. longitude: req.getStorage('loctionAddressMap').location.lng,
  141. width: 75,
  142. height: 99,
  143. iconPath: '/static/images/nearby.png',
  144. // joinCluster: true
  145. }
  146. cover.unshift(obj);
  147. return cover;
  148. },
  149. async getLoca(){
  150. this.map.moveToLocation({latitude:this.latitude,longitude:this.longitude},res=>{})
  151. // this.covers = [];
  152. // this.latitude = req.getStorage('loctionAddressMap').location.lat;
  153. // this.longitude = req.getStorage('loctionAddressMap').location.lng;
  154. // await this.getCabList();
  155. },
  156. async regionChange(e){
  157. // console.log('视野发生变化时触发',e)
  158. // if(e.type == 'end' && e.causedBy == 'drag'){
  159. // this.covers = [];
  160. // this.latitude = e.detail.centerLocation.latitude;
  161. // this.longitude = e.detail.centerLocation.longitude;
  162. // await this.getCabList();
  163. // }
  164. },
  165. async clickMap(e){
  166. console.log('e==',e.detail)
  167. let markerId = e.detail.markerId
  168. let index = this.covers.findIndex(item=>item.id==markerId)
  169. // if(this.markerId == this.covers[markerId-1].column && this.markerId != 0) return false;
  170. this.cabBottom = '-100%';
  171. this.storeBottom = '-100%';
  172. this.getCabInfo(index);
  173. let covers = [];
  174. // this.covers = []
  175. if(this.covers&&this.covers.length>0){
  176. for(let i=0;i<this.covers.length;i++){
  177. let it = this.covers[i]
  178. if(it.id==markerId){
  179. let markerLogo = await this.getMarkerLogo(it.logo,it.id==markerId?2:null)
  180. let obj = {
  181. latitude: it.latitude,
  182. longitude: it.longitude,
  183. width: 80,
  184. height: 92,
  185. logo:it.logo,
  186. id:it.id,
  187. // iconPath: '/static/images/jg_map_ico.png',
  188. // 'https://img.zhiqiyun.com/test/2023/07/27/ec50eeee1ab3358d9ba397c86ae8fcc6.jpeg'
  189. iconPath: markerLogo//显示的图标
  190. // radius: it.column_4[0].radius,//检索的半径,单位为米
  191. // joinCluster: true
  192. }
  193. covers.push(obj)
  194. }else{
  195. covers.push(it)
  196. }
  197. }
  198. }
  199. this.covers = JSON.parse(JSON.stringify(covers))
  200. this.$forceUpdate()
  201. // console.log('covers==',this.covers[markerId-1])
  202. // console.log('this.circles=',this.circles[0])
  203. },
  204. timeRange(beginTime, endTime) {
  205. let strb = beginTime.split(":");
  206. if (strb.length != 2) {
  207. return false;
  208. }
  209. let stre = endTime.split(":");
  210. if (stre.length != 2) {
  211. return false;
  212. }
  213. let b = new Date();
  214. let e = new Date();
  215. let n = new Date();
  216. b.setHours(strb[0]);
  217. b.setMinutes(strb[1]);
  218. e.setHours(stre[0]);
  219. e.setMinutes(stre[1]);
  220. if (n.getTime() - b.getTime() >= 0 && n.getTime() - e.getTime() < 0) {
  221. return true;
  222. } else {
  223. return false;
  224. }
  225. },
  226. captureTime(time,isTime){
  227. return util.captureTime(time,isTime)
  228. },
  229. getCabList(){
  230. let that = this;
  231. let form = {
  232. latitude: this.latitude,
  233. longitude: this.longitude,
  234. page:1,
  235. limit:30
  236. // distance: 2000
  237. }
  238. return new Promise(async(resolve,reject)=>{
  239. req.getRequest('/api/visiting/card/cardInfoList',form,async res=>{
  240. this.cabList = res.list;
  241. this.getCabInfo(0)
  242. let data = {list:[]}
  243. data.list = res.list.map(item=>{
  244. let obj = {
  245. userId:item.id,
  246. latitude:item.latitude,
  247. longitude:item.longitude,
  248. logo:item.avatar
  249. }
  250. return obj
  251. })
  252. let covers = this.covers; //this.addNearby();
  253. if(data.list&&data.list.length>0){
  254. for(let i=0;i<data.list.length;i++){
  255. let it = data.list[i]
  256. let markerLogo = await this.getMarkerLogo(it.logo)
  257. let obj = {
  258. latitude: it.latitude,
  259. longitude: it.longitude,
  260. width: 80,
  261. height: 92,
  262. logo:it.logo,
  263. // iconPath: '/static/images/jg_map_ico.png',
  264. // 'https://img.zhiqiyun.com/test/2023/07/27/ec50eeee1ab3358d9ba397c86ae8fcc6.jpeg'
  265. iconPath: markerLogo//显示的图标
  266. // radius: it.column_4[0].radius,//检索的半径,单位为米
  267. // joinCluster: true
  268. }
  269. covers.push(obj);
  270. }
  271. }
  272. if(covers.length > 0){
  273. covers.map((it,index)=>{
  274. it.id = index+1;
  275. return it;
  276. })
  277. }
  278. that.covers = covers
  279. resolve();
  280. })
  281. })
  282. },
  283. getCabInfo(index){
  284. this.cabInfo = this.cabList[index];
  285. this.cabBottom = 0;
  286. },
  287. routePlan(type){
  288. let that = this;
  289. let plugin = requirePlugin('routePlan');
  290. let key = req.public.mapLBSKEY; //使用在腾讯位置服务申请的key
  291. let referer = '线上会客厅系统'; //调用插件的app的名称
  292. let endPoint = '';
  293. if(type == 1){
  294. endPoint = JSON.stringify({ //终点
  295. 'name': that.cabInfo.devName,
  296. 'latitude': that.cabInfo.latitude,
  297. 'longitude': that.cabInfo.longitude
  298. });
  299. }else{
  300. endPoint = JSON.stringify({ //终点
  301. 'name': that.storeInfo.name,
  302. 'latitude': that.storeInfo.latitude,
  303. 'longitude': that.storeInfo.longitude
  304. });
  305. }
  306. console.log('endPoint==',endPoint)
  307. wx.navigateTo({
  308. url: 'plugin://routePlan/index?key=' + key + '&referer=' + referer + '&endPoint=' + endPoint
  309. });
  310. },
  311. callPhone(number){
  312. uni.makePhoneCall({
  313. phoneNumber: number
  314. })
  315. },
  316. hideCab(){
  317. this.cabBottom = '-100%';
  318. this.markerId = '';
  319. },
  320. showCab(){
  321. this.isShowCab = true;
  322. },
  323. jumpUrl(url){
  324. if (!req.isLogins(true)) return false;
  325. uni.navigateTo({
  326. url: url
  327. })
  328. },
  329. getAge(date) {
  330. return util.getAge(date)
  331. },
  332. // 获取markerLogo
  333. getMarkerLogo(url,type){
  334. // 多次绘图时重置canvas
  335. this.canvasShow = true
  336. let that = this
  337. return new Promise(async(re,rj)=>{
  338. let mapBgUrl = 'https://img.zhiqiyun.com/test/2023/07/27/2d30f06817365b83a5f78c455fce8974.png'
  339. if(type&&type==2) mapBgUrl = 'https://img.zhiqiyun.com/test/2023/07/27/ad0bfade8dcffa6b20c045a53945dea3.png'
  340. console.log('mapBgUrl',mapBgUrl)
  341. const avatarp = this.getImageInfo(url); // 获取小程序码图
  342. const mapBg = this.getImageInfo(mapBgUrl); // 获取小程序码图
  343. Promise.all([avatarp,mapBg]).then(([avatar,mapIcon]) => {
  344. const ctx = uni.createCanvasContext('logoIcon', this); // 绘制背景,填充满整个canvas画布
  345. let width = 80,
  346. height = 92; //默认背景
  347. // ctx.setFillStyle('transparent');
  348. // ctx.fillRect(0, 0, width, height); // 画布背景
  349. ctx.drawImage(mapIcon.path, 0, 0, width, height); //绘制图片
  350. // ctx.save();
  351. // ctx.restore();
  352. // ctx.beginPath();
  353. const avatarW = width-28;
  354. that.roundRect(ctx, 14, 12, avatarW, avatarW, avatarW/2);
  355. ctx.clip(); //裁剪
  356. ctx.drawImage(avatar.path, 14, 12, avatarW, avatarW);
  357. ctx.restore();
  358. ctx.draw(false, function() {
  359. uni.canvasToTempFilePath({
  360. canvasId: 'logoIcon',
  361. success: function(res) {
  362. console.log('ctx.draw',res.tempFilePath)
  363. that.canvasShow = false
  364. re(res.tempFilePath)
  365. },
  366. fail: function(res) {
  367. console.log(res)
  368. rj()
  369. }
  370. }, that);
  371. });
  372. })
  373. })
  374. },
  375. getImageInfo(url) {
  376. console.log('getImageInfo',url)
  377. return new Promise((resolve, reject) => {
  378. if (!url) {
  379. resolve();
  380. return false;
  381. }
  382. uni.getImageInfo({
  383. src: url,
  384. success: resolve,
  385. fail: reject
  386. });
  387. });
  388. },
  389. /**
  390. *
  391. * @param {CanvasContext} ctx canvas上下文
  392. * @param {number} x 圆角矩形选区的左上角 x坐标
  393. * @param {number} y 圆角矩形选区的左上角 y坐标
  394. * @param {number} w 圆角矩形选区的宽度
  395. * @param {number} h 圆角矩形选区的高度
  396. * @param {number} r 圆角的半径
  397. */
  398. roundRect: function(ctx, x, y, w, h, r) {
  399. // 开始绘制
  400. ctx.beginPath(); // 因为边缘描边存在锯齿,最好指定使用 transparent 填充
  401. // 这里是使用 fill 还是 stroke都可以,二选一即可
  402. ctx.setFillStyle('white'); // ctx.setStrokeStyle('transparent')
  403. // 左上角
  404. ctx.arc(x + r, y + r, r, Math.PI, Math.PI * 1.5); // border-top
  405. ctx.moveTo(x + r, y);
  406. ctx.lineTo(x + w - r, y);
  407. ctx.lineTo(x + w, y + r); // 右上角
  408. ctx.arc(x + w - r, y + r, r, Math.PI * 1.5, Math.PI * 2); // border-right
  409. ctx.lineTo(x + w, y + h - r);
  410. ctx.lineTo(x + w - r, y + h); // 右下角
  411. ctx.arc(x + w - r, y + h - r, r, 0, Math.PI * 0.5); // border-bottom
  412. ctx.lineTo(x + r, y + h);
  413. ctx.lineTo(x, y + h - r); // 左下角
  414. ctx.arc(x + r, y + h - r, r, Math.PI * 0.5, Math.PI); // border-left
  415. ctx.lineTo(x, y + r);
  416. ctx.lineTo(x + r, y); // 这里是使用 fill 还是 stroke都可以,二选一即可,但是需要与上面对应
  417. ctx.fill(); // ctx.stroke()
  418. ctx.closePath(); // 剪切
  419. ctx.clip();
  420. }
  421. },
  422. }
  423. </script>
  424. <style>
  425. @import "./cardFound.css";
  426. </style>