cardFound.vue 14 KB

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