index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. <template>
  2. <view class="content">
  3. <view class="swiper-item" style="padding: 0 15px;">
  4. <view class="chart-box">
  5. <view class="navbar-list">
  6. <u-image width="220rpx" height="80rpx" v-for="(item,index) in navbarList" :key="index" :src="item.imgPath" :fade="false" @click="handleJumpPathClick(item)"></u-image>
  7. </view>
  8. <!-- 简报 -->
  9. <view class="bulletin-list">
  10. <u-tabs :list="bulletinList" :is-scroll="false" bg-color="#f5f6f8" :current="bulletinCurrent" :active-item-style="{'fontSize': '44rpx', 'color':'#000','width':'280rpx'}" font-size="36" @change="handlebulletinClick"></u-tabs>
  11. <!-- <u-cell-item title="本周" :arrow="true" arrow-direction="down"></u-cell-item> -->
  12. <u-cell-item title="本周" :arrow="false"></u-cell-item>
  13. </view>
  14. <!-- 简报信息 -->
  15. <u-card :show-head="false" :show-foot="false" :border="false" margin="20rpx 0">
  16. <view slot="body" class="bulletin-info">
  17. <view v-for="(item,index) in bulletinInfo" :key="index" class="bulletin-item">
  18. <view>{{ item.name }}</view>
  19. <view class="bulletin-num">{{ item.num }}</view>
  20. </view>
  21. </view>
  22. </u-card>
  23. <!-- 线索状态 -->
  24. <u-card :show-foot="false" :border="false" margin="0px">
  25. <view slot="head">
  26. <text style="font-size: 44rpx;font-weight: bold;">线索状态</text>
  27. </view>
  28. <view slot="body">
  29. <canvas canvas-id="chartBox" id="chartBox" class="chart-canvas" force-use-old-canvas="true"></canvas>
  30. </view>
  31. </u-card>
  32. <!-- 场馆推荐-->
  33. <u-card :show-foot="false" :border="false" margin="20rpx 0">
  34. <view slot="head">
  35. <u-section title="场馆推荐" sub-title="查看更多" font-size="44" :show-line="false" @click="goToVenueList()"></u-section>
  36. </view>
  37. <view class="class-show-box" slot="body">
  38. <view v-for="(item, index) in videoList" :key="index" class="class-show-card" @click="goToVenueDetail(item)">
  39. <u-image :src="item.url" mode="aspectFill" height="30vw" border-radius="10px"></u-image>
  40. <view class="class-show-name">{{item.name}}</view>
  41. </view>
  42. </view>
  43. </u-card>
  44. </view>
  45. </view>
  46. <u-top-tips ref="uTips"></u-top-tips>
  47. <!-- <u-tabbar v-model="current" :list="tabbarList" :mid-button="true" :active-color="mainColor" inactive-color="#cccccc"
  48. icon-size="60"></u-tabbar> -->
  49. </view>
  50. </template>
  51. <script>
  52. import {
  53. mapGetters
  54. } from 'vuex'
  55. import uCharts from '@/js_sdk/u-charts/u-charts/u-charts.min.js';
  56. import client from '@/static/images/client.png'
  57. import thread from '@/static//images/thread.png'
  58. import business from '@/static/images/business.png'
  59. import empty from '@/static/images/empty.png'
  60. const NET = require('@/utils/request')
  61. const API = require('@/config/api')
  62. var _self;
  63. var uChartsInstance = {};
  64. export default {
  65. computed: {
  66. ...mapGetters([
  67. 'mainColor',
  68. 'customStyle',
  69. ])
  70. },
  71. data() {
  72. return {
  73. cWidth: '',
  74. cHeight: '',
  75. longitude: '',
  76. latitude: '',
  77. sectionIcon: API.getServerImg + 'biaoti.png',
  78. enrolledIcon: API.getServerImg + 'yibaoming.png ',
  79. intentionIcon: API.getServerImg + 'yixiangkehu.png',
  80. videoList: [],
  81. tabbarList: [{
  82. iconPath: "../../../static/images/icon-index.png",
  83. selectedIconPath: "../../../static/images/icon-index-active.png",
  84. text: '首页',
  85. customIcon: false,
  86. },
  87. {
  88. iconPath: "plus-circle-fill",
  89. selectedIconPath: "close-circle-fill",
  90. text: '新增',
  91. midButton: true,
  92. customIcon: false,
  93. },
  94. {
  95. iconPath: "../../../static/images/icon-mine.png",
  96. selectedIconPath: "../../../static/images/icon-mine-active.png",
  97. text: '我的',
  98. customIcon: false,
  99. },
  100. ],
  101. userData: {
  102. headImage: '',
  103. userId: '',
  104. nickName: '',
  105. userName: '',
  106. phone: '',
  107. },
  108. navbarList: [
  109. {
  110. 'title': '客户',
  111. 'imgPath': client,
  112. 'path': '/pagesMain/customerList'
  113. },
  114. {
  115. 'title': '线索',
  116. 'imgPath': thread,
  117. 'path': '/pagesMain/threadList'
  118. },
  119. {
  120. 'title': '公海',
  121. 'imgPath': business,
  122. 'path': '/pagesMain/businessList'
  123. },
  124. // {
  125. // 'title': '占位',
  126. // 'imgPath': empty,
  127. // }
  128. ],
  129. // 简报
  130. bulletinList: [{
  131. name: '团队简报'
  132. }, {
  133. name: '个人简报'
  134. }],
  135. bulletinCurrent: 0,
  136. // 简报信息
  137. bulletinInfo: [
  138. {
  139. name: '新增客户',
  140. num: 0
  141. }, {
  142. name: '新增线索',
  143. num: 0
  144. }, {
  145. name: '新增商机',
  146. num: 0
  147. }
  148. ],
  149. flag: true,
  150. // 线索状态
  151. threadList: [],
  152. threadNum: 0
  153. }
  154. },
  155. onLoad() {
  156. // _self = this; // 浏览器调试时需要打开,微信调试时需关闭
  157. if (!uni.getStorageSync('token')) {
  158. uni.navigateTo({
  159. url: '/pages/login/index'
  160. });
  161. }
  162. },
  163. onReady() {
  164. //这里的 750 对应 css .charts 的 width
  165. this.cWidth = uni.upx2px(520);
  166. //这里的 500 对应 css .charts 的 height
  167. this.cHeight = uni.upx2px(500);
  168. },
  169. onShow() {
  170. if (uni.getStorageSync('userData')) {
  171. this.userData = uni.getStorageSync('userData')
  172. }
  173. uni.getLocation({
  174. type: 'wgs84',
  175. geocode: true,
  176. success: (res) => {
  177. uni.setStorage({
  178. key: 'locationData',
  179. data: {
  180. longitude: res.longitude,
  181. latitude: res.latitude,
  182. }
  183. })
  184. this.initialize()
  185. }
  186. });
  187. },
  188. onPullDownRefresh() {
  189. this.initialize()
  190. setTimeout(() => {
  191. uni.stopPullDownRefresh();
  192. }, 500)
  193. },
  194. methods: {
  195. // 跳页
  196. handleJumpPathClick(item) {
  197. uni.navigateTo({
  198. url: item.path
  199. })
  200. },
  201. drawCharts(id,data){
  202. const ctx = uni.createCanvasContext(id, this);
  203. uChartsInstance[id] = new uCharts({
  204. type: "ring",
  205. context: ctx,
  206. width: this.cWidth,
  207. height: this.cHeight,
  208. series: data.series,
  209. animation: true,
  210. rotate: false,
  211. rotateLock: false,
  212. background: "#FFFFFF",
  213. color: ["#8A2BE8","#91CB74","#FAC858","#EE6666","#1890FF"],
  214. padding: [0,0,0,0],
  215. dataLabel: false,
  216. legend: {
  217. show: true,
  218. position: "right",
  219. lineHeight: 25
  220. },
  221. title: {
  222. name: this.threadNum,
  223. fontSize: 24,
  224. color: "#000"
  225. },
  226. subtitle: {
  227. name: "线索量",
  228. fontSize: 18,
  229. color: "#000"
  230. },
  231. extra: {
  232. ring: {
  233. ringWidth: 25,
  234. offsetAngle: 0,
  235. labelWidth: 15,
  236. border: false,
  237. }
  238. }
  239. })
  240. },
  241. // 获取初始化数据
  242. initialize() {
  243. this.getTeamPaper()
  244. this.getClueRait()
  245. // this.getRing()
  246. NET.request(API.getNearVenueList, uni.getStorageSync('locationData'), 'POST').then(res => {
  247. const venueData = res.data
  248. this.videoList = venueData.length <= 4 ? venueData : venueData.slice(0,4)
  249. }).catch(error => {
  250. this.$refs.uTips.show({
  251. title: error.message,
  252. type: 'warning',
  253. })
  254. })
  255. },
  256. // 获取团队简报
  257. async getTeamPaper() {
  258. let res = await NET.request(API.teamStatistics, { flag: this.flag }, 'POST')
  259. if(res.status == 10000) {
  260. const result = res.data
  261. this.bulletinInfo[0].num = result.nearCreateCustomer
  262. this.bulletinInfo[1].num = result.nearCreateClue
  263. this.bulletinInfo[2].num = result.nearCreateChance
  264. } else {
  265. this.$refs.uTips.show({
  266. title: res.message,
  267. type: 'warning',
  268. })
  269. }
  270. },
  271. // 获取线索状态
  272. async getClueRait() {
  273. let res = await NET.request(API.clueRait, { flag: this.flag }, 'POST')
  274. if(res.status == 10000) {
  275. // 线索
  276. this.threadList = res.data.map(item => {
  277. return {
  278. 'name': `${item.name}(${item.value})` ,
  279. 'value': item.value
  280. }
  281. })
  282. // 线索量
  283. this.threadNum = res.data.reduce((sum,item) => sum += item.value, 0 )
  284. } else {
  285. this.$refs.uTips.show({
  286. title: res.message,
  287. type: 'warning',
  288. })
  289. }
  290. let aaa = {
  291. series: [
  292. {
  293. data: this.threadList
  294. // data: [{'name':"一班(20)","value":500},{'name':"二班","value":30},{'name':"三班","value":20},{'name':"四班","value":18}]
  295. // data: threadList
  296. }
  297. ]
  298. };
  299. this.drawCharts('chartBox', aaa);
  300. },
  301. // 图
  302. // getRing() {
  303. // // console.log(threadList);
  304. // let res = {
  305. // series: [
  306. // {
  307. // // data: this.threadList
  308. // data: [{'name':"一班(20)","value":500},{'name':"二班","value":30},{'name':"三班","value":20},{'name':"四班","value":18}]
  309. // // data: threadList
  310. // }
  311. // ]
  312. // };
  313. // this.drawCharts('chartBox', res);
  314. // },
  315. // 切换简报
  316. handlebulletinClick(index) {
  317. this.bulletinCurrent = index
  318. if(!index) {
  319. this.flag = true
  320. } else {
  321. this.flag = false
  322. }
  323. this.getTeamPaper()
  324. this.getClueRait()
  325. },
  326. // 跳转今日新增
  327. goToTodayEnroll() {
  328. uni.navigateTo({
  329. url: '/pagesEnroll/todayEnroll'
  330. });
  331. },
  332. // 跳转所有场馆
  333. goToVenueList() {
  334. uni.navigateTo({
  335. url: '/pagesEnroll/venueList'
  336. });
  337. },
  338. // 跳转场馆详情
  339. goToVenueDetail(item) {
  340. uni.navigateTo({
  341. url: '/pagesEnroll/venueDetail?id=' + item.id
  342. });
  343. },
  344. // 跳转添加信息
  345. goToAddForm(path) {
  346. uni.removeStorageSync('defaultClass');
  347. uni.navigateTo({
  348. url: '/pagesEnroll/' + path
  349. });
  350. },
  351. },
  352. }
  353. </script>
  354. <style lang="scss" scoped>
  355. @import "@/static/css/themes.scss";
  356. .content {
  357. width: 100%;
  358. float: left;
  359. background-color: #f5f6f8;
  360. .swiper-item {
  361. width: 100%;
  362. height: calc(100vh - 50px);
  363. position: relative;
  364. }
  365. .chart-box {
  366. width: 100%;
  367. // height: 240px;
  368. float: left;
  369. padding: 10px 0;
  370. .navbar-list {
  371. display: flex;
  372. justify-content: space-between;
  373. width:100%;
  374. }
  375. .bulletin-list {
  376. display:flex;
  377. align-items: center;
  378. justify-content: space-between;
  379. margin-top: 20rpx;
  380. }
  381. .bulletin-info {
  382. display: flex;
  383. justify-content: space-between;
  384. align-items: center;
  385. .bulletin-item {
  386. flex:1;display: flex;
  387. flex-direction:column;
  388. justify-content: center;
  389. align-items: center;
  390. .bulletin-num {
  391. font-size: 18px;
  392. font-weight: bold;
  393. margin-top: 10rpx;
  394. }
  395. }
  396. }
  397. .chart-canvas {
  398. width: 100%;
  399. height: 500rpx;
  400. }
  401. }
  402. .section-title {
  403. width: 100%;
  404. // height: 28px;
  405. display: flex;
  406. align-items: center;
  407. u-section {
  408. margin-left: 10px;
  409. flex: 1;
  410. }
  411. }
  412. .class-show-box {
  413. width: calc(100% + 32px);
  414. margin: 0 -16px;
  415. float: left;
  416. // padding-bottom: 50px;
  417. .class-show-card {
  418. width: calc(50% - 16px);
  419. margin: 0 8px 16px 8px;
  420. float: left;
  421. .class-show-name {
  422. width: 100%;
  423. text-align: center;
  424. line-height: 18px;
  425. font-size: 12px;
  426. margin-top: 5px;
  427. }
  428. }
  429. }
  430. .enroll-fix-box {
  431. width: 100%;
  432. height: 90px;
  433. position: absolute;
  434. bottom: 40px;
  435. left: 0;
  436. display: flex;
  437. justify-content: space-around;
  438. .enroll-button {
  439. width: 60px;
  440. height: 90px;
  441. .enroll-img {
  442. width: 60px;
  443. height: 60px;
  444. padding-left: 5px;
  445. border-radius: 50%;
  446. background-color: #ffffff;
  447. box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.2);
  448. display: flex;
  449. justify-content: center;
  450. align-items: center;
  451. }
  452. .enroll-text {
  453. width: 60px;
  454. height: 20px;
  455. margin-top: 10px;
  456. line-height: 20px;
  457. font-size: 14px;
  458. text-align: center;
  459. white-space: nowrap;
  460. }
  461. }
  462. }
  463. .user-info {
  464. width: 100%;
  465. height: 110px;
  466. margin-bottom: 20px;
  467. float: left;
  468. background-color: $mainColor;
  469. .user-data {
  470. width: calc(100% - 110px);
  471. height: 110px;
  472. padding: 15px 0 15px 15px;
  473. float: left;
  474. .user-name {
  475. width: 100%;
  476. float: left;
  477. font-size: 24px;
  478. color: #FFFFFF;
  479. line-height: 30px;
  480. margin: 10px 0;
  481. white-space: nowrap;
  482. overflow: hidden;
  483. text-overflow: ellipsis;
  484. }
  485. .user-phone {
  486. width: 100%;
  487. color: #FFFFFF;
  488. line-height: 20px;
  489. float: left;
  490. white-space: nowrap;
  491. overflow: hidden;
  492. text-overflow: ellipsis;
  493. }
  494. }
  495. .user-img {
  496. width: 110px;
  497. height: 110px;
  498. padding: 15px;
  499. float: left;
  500. display: flex;
  501. align-items: center;
  502. justify-content: center;
  503. }
  504. }
  505. .user-handle {
  506. width: 100vw;
  507. height: 40px;
  508. float: left;
  509. padding: 0 15px;
  510. margin-bottom: 10px;
  511. display: flex;
  512. align-items: center;
  513. .handle-icon {
  514. width: 40px;
  515. height: 40px;
  516. text-align: center;
  517. line-height: 40px;
  518. display: flex;
  519. align-items: center;
  520. }
  521. .handle-label {
  522. height: 40px;
  523. flex: 1;
  524. margin-left: 10px;
  525. line-height: 40px;
  526. font-size: 15px;
  527. }
  528. .handle-arrow {
  529. line-height: 40px;
  530. }
  531. }
  532. }
  533. </style>