index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <template>
  2. <div class="buildmap">
  3. <van-tabs :active="active" @change="onChange">
  4. <van-tab title="活跃度排行"> </van-tab>
  5. <van-tab title="党支部地图">
  6. <view class="page-main">
  7. <div>
  8. <uni-search-bar
  9. :radius="100"
  10. style="
  11. position: absolute;
  12. z-index: 10000;
  13. width: 96vw;
  14. padding: 0 2vw;
  15. "
  16. placeholder="搜索党支部"
  17. v-model="searchName"
  18. @cancel="cancel"
  19. @confirm="searchMap"
  20. />
  21. </div>
  22. <liu-easy-map
  23. ref="liuEasyMap"
  24. :scale="14"
  25. :markerData="markerData"
  26. @clickMarker="markerClick"
  27. />
  28. </view>
  29. </van-tab>
  30. </van-tabs>
  31. <div style="position: absolute; width: 100%">
  32. <div class="bluebg">
  33. <div
  34. @click="showTimePicker = true"
  35. style="
  36. display: flex;
  37. width: 344rpx;
  38. display: flex;
  39. height: 60rpx;
  40. justify-content: space-around;
  41. line-height: 60rpx;
  42. color: white;
  43. border-radius: 32rpx;
  44. border: 2rpx solid rgba(255, 255, 255, 0.53);
  45. background: rgba(255, 255, 255, 0.2);
  46. margin-top: 32rpx;
  47. float: right;
  48. margin-right: 70rpx;
  49. "
  50. >
  51. <div>{{ week }}</div>
  52. <uni-icons type="bottom" size="20"></uni-icons>
  53. </div>
  54. </div>
  55. <div class="top3">
  56. <div class="top3first">
  57. <div
  58. :class="index == list.lenght ? 'top3-row' : 'top3-row top3borderbt'"
  59. v-for="(item, index) in list"
  60. :key="index"
  61. v-if="index == 0 || index == 1 || index == 2"
  62. >
  63. <img :src="require(`./top${index + 1}.png`)" width="40rpx" alt="" />
  64. <div class="depname">{{ item.branchName }}</div>
  65. <div class="bili">{{ item.activationRate + "%" }}</div>
  66. </div>
  67. </div>
  68. <div
  69. class="top3-1"
  70. style="background: white; padding: 10rpx 0; margin-top: 22rpx"
  71. >
  72. <div
  73. :class="index == list.lenght ? 'top3-row' : 'top3-row top3borderbt'"
  74. v-for="(item, index) in list"
  75. :key="index"
  76. v-if="index != 0 && index != 1 && index != 2"
  77. >
  78. <div
  79. style="
  80. height: 40rpx;
  81. width: 40rpx;
  82. text-align: center;
  83. line-height: 40rpx;
  84. color: #777777;
  85. "
  86. >
  87. {{ index + 1 }}
  88. </div>
  89. <div class="depname">{{ item.branchName }}</div>
  90. <div class="bili">{{ item.activationRate + "%" }}</div>
  91. </div>
  92. </div>
  93. </div>
  94. </div>
  95. <lys-date
  96. ref="lysdate"
  97. v-if="showTimePicker"
  98. :type="2"
  99. :time="time"
  100. @cancleTime="showTimePicker = false"
  101. @submitTime="submitTime"
  102. />
  103. </div>
  104. </template>
  105. <script>
  106. // import * as lys from "../../../uni_modules/lys-jsUtils.js";
  107. // uni.$lys = lys;
  108. import { getPartyBranchList, getActivationRanking } from "@/js_sdk/http.js";
  109. export default {
  110. data() {
  111. return {
  112. showTimePicker: false,
  113. searchName: "",
  114. markerData: [],
  115. //展示区域点位信息
  116. polygons: [],
  117. list: [],
  118. week: "",
  119. };
  120. },
  121. onShow() {
  122. const date = new Date();
  123. console.log("第几年", date.getFullYear());
  124. let week =
  125. date.getFullYear() +
  126. "第" +
  127. this.getYearWeek(
  128. date.getFullYear(),
  129. Number(date.getMonth()) + 1,
  130. date.getDate()
  131. ) +
  132. "周";
  133. console.log(week);
  134. this.week = week;
  135. this.getActivationRanking(week);
  136. },
  137. methods: {
  138. async getActivationRanking(e) {
  139. let { data } = await getActivationRanking({ week: e });
  140. console.log(data);
  141. this.list = data;
  142. },
  143. getYearWeek(a, b, c) {
  144. //a为年 b为月 c为日
  145. /*
  146. date1是当前日期
  147. date2是当年第一天
  148. d是当前日期是今年第多少天
  149. 用d + 当前年的第一天的周差距的和在除以7就是本年第几周
  150. */
  151. var date1 = new Date(a, parseInt(b) - 1, c),
  152. date2 = new Date(a, 0, 1),
  153. d = Math.round((date1.valueOf() - date2.valueOf()) / 86400000);
  154. return Math.ceil((d + (date2.getDay() + 1 - 1)) / 7);
  155. },
  156. submitTime(e) {
  157. this.week = e;
  158. this.showTimePicker = false;
  159. console.log(e);
  160. this.getActivationRanking(e);
  161. },
  162. onChange(e) {
  163. console.log(e.detail.name);
  164. if (e.detail.name == 1) {
  165. this.getPartyBranchList();
  166. }
  167. },
  168. cancel() {
  169. this.searchName = "";
  170. this.getPartyBranchList();
  171. },
  172. async searchMap() {
  173. // changeCenter
  174. let { data } = await getPartyBranchList({ searchName: this.searchName });
  175. this.markerData = data.map((e, index, array) => {
  176. return {
  177. latitude: e.branchLat,
  178. longitude: e.branchLng,
  179. name: e.branchName,
  180. mapid: e.id,
  181. id: index,
  182. address: e.branchName,
  183. iconWidth: 32, //标记点图标宽度
  184. iconHeight: 32, //标记点图标高度
  185. calloutColor: "#798DF3", //气泡窗口 文本颜色
  186. calloutFontSize: 16, //气泡窗口 文本大小
  187. calloutBorderRadius: 6, //气泡窗口 边框圆角
  188. calloutPadding: 8, //气泡窗口 文本边缘留白
  189. calloutBgColor: "#00000000", //气泡窗口 背景颜色
  190. calloutDisplay: "ALWAYS", //气泡窗口 展示类型 默认常显 'ALWAYS' 常显 'BYCLICK' 点击显示
  191. markerUrl: require("./markerone.png"),
  192. };
  193. });
  194. this.$refs.liuEasyMap.changeCenter({
  195. latitude: this.markerData[0].latitude,
  196. longitude: this.markerData[0].longitude,
  197. });
  198. this.$refs.liuEasyMap.showMarkers();
  199. },
  200. async getPartyBranchList() {
  201. let { data } = await getPartyBranchList({ searchName: this.searchName });
  202. console.log(data);
  203. this.markerData = data.map((e, index, array) => {
  204. return {
  205. latitude: e.branchLat,
  206. longitude: e.branchLng,
  207. name: e.branchName,
  208. mapid: e.id,
  209. id: index,
  210. address: e.branchName,
  211. iconWidth: 32, //标记点图标宽度
  212. iconHeight: 32, //标记点图标高度
  213. calloutColor: "#798DF3", //气泡窗口 文本颜色
  214. calloutFontSize: 16, //气泡窗口 文本大小
  215. calloutBorderRadius: 6, //气泡窗口 边框圆角
  216. calloutPadding: 8, //气泡窗口 文本边缘留白
  217. calloutBgColor: "#00000000", //气泡窗口 背景颜色
  218. calloutDisplay: "ALWAYS", //气泡窗口 展示类型 默认常显 'ALWAYS' 常显 'BYCLICK' 点击显示
  219. markerUrl: require("./markerone.png"),
  220. };
  221. });
  222. this.$refs.liuEasyMap.showMarkers();
  223. },
  224. //点击标记点
  225. markerClick(e) {
  226. console.log("点击标记点信息:", e);
  227. },
  228. },
  229. };
  230. </script>
  231. <style lang="scss">
  232. .top3first {
  233. background: url(./topfirst3.png) no-repeat;
  234. border-radius: 1rem;
  235. background-size: 100% 100%;
  236. padding: 10rpx;
  237. }
  238. .page-main {
  239. width: 100%;
  240. height: 100vh;
  241. }
  242. .buildmap {
  243. .top3borderbt {
  244. border-bottom: 2rpx solid rgba(204, 204, 204, 0.4);
  245. }
  246. .top3-1 {
  247. background: url(./topfirst3.png) no-repeat;
  248. background-size: 100% 100%;
  249. width: 100%;
  250. border-radius: 1rem;
  251. }
  252. .top3 {
  253. // height: 343rpx;
  254. background-size: 100% 100%;
  255. width: 80%;
  256. position: relative;
  257. top: 115rpx;
  258. left: 10%;
  259. border-radius: 1rem;
  260. .top3-row {
  261. display: flex;
  262. margin: 32rpx 32rpx 0 32rpx;
  263. padding-bottom: 24rpx;
  264. img {
  265. width: 40rpx;
  266. height: 40rpx;
  267. margin-right: 24rpx;
  268. }
  269. .depname {
  270. color: #162485;
  271. /* height: 40rpx; */
  272. line-height: 40rpx;
  273. font-size: 28rpx;
  274. width: 80%;
  275. }
  276. .bili {
  277. width: 116rpx;
  278. text-align: center;
  279. border-radius: 15rem;
  280. height: 40rpx;
  281. line-height: 40rpx;
  282. font-weight: 400;
  283. background: rgba(33, 85, 244, 0.05);
  284. color: #798df3;
  285. margin-left: auto;
  286. }
  287. }
  288. }
  289. .bluebg {
  290. width: 100%;
  291. height: 260rpx;
  292. background: linear-gradient(132deg, #3c53f0 0%, #1026c3 100%);
  293. position: absolute;
  294. }
  295. .uni-searchbar {
  296. background: white;
  297. padding: 0;
  298. margin-top: 10rpx;
  299. border-radius: 100rpx;
  300. .uni-searchbar__box {
  301. background: white !important;
  302. }
  303. .uni-searchbar__cancel {
  304. padding: 0 !important;
  305. text-align: left !important;
  306. width: 75rpx !important;
  307. }
  308. }
  309. }
  310. </style>