index.vue 12 KB

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