index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  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.business)
  183. //this.navbarList.push(this.empty)
  184. }
  185. }
  186. uni.getLocation({
  187. type: 'wgs84',
  188. geocode: true,
  189. success: (res) => {
  190. uni.setStorage({
  191. key: 'locationData',
  192. data: {
  193. longitude: res.longitude,
  194. latitude: res.latitude,
  195. }
  196. })
  197. this.initialize()
  198. }
  199. });
  200. },
  201. onPullDownRefresh() {
  202. this.initialize()
  203. setTimeout(() => {
  204. uni.stopPullDownRefresh();
  205. }, 500)
  206. },
  207. methods: {
  208. // 跳页
  209. handleJumpPathClick(item) {
  210. uni.navigateTo({
  211. url: item.path
  212. })
  213. },
  214. drawCharts(id,data){
  215. const ctx = uni.createCanvasContext(id, this);
  216. uChartsInstance[id] = new uCharts({
  217. type: "ring",
  218. context: ctx,
  219. width: this.cWidth,
  220. height: this.cHeight,
  221. series: data.series,
  222. animation: true,
  223. rotate: false,
  224. rotateLock: false,
  225. background: "#FFFFFF",
  226. color: ["#8A2BE8","#91CB74","#FAC858","#EE6666","#1890FF"],
  227. padding: [0,0,0,0],
  228. dataLabel: false,
  229. legend: {
  230. show: true,
  231. position: "right",
  232. lineHeight: 25
  233. },
  234. title: {
  235. name: this.threadNum,
  236. fontSize: 24,
  237. color: "#000"
  238. },
  239. subtitle: {
  240. name: "线索量",
  241. fontSize: 18,
  242. color: "#000"
  243. },
  244. extra: {
  245. ring: {
  246. ringWidth: 25,
  247. offsetAngle: 0,
  248. labelWidth: 15,
  249. border: false,
  250. }
  251. }
  252. })
  253. },
  254. // 获取初始化数据
  255. initialize() {
  256. this.getTeamPaper()
  257. this.getClueRait()
  258. // this.getRing()
  259. NET.request(API.getNearVenueList, uni.getStorageSync('locationData'), 'POST').then(res => {
  260. const venueData = res.data
  261. this.videoList = venueData.length <= 4 ? venueData : venueData.slice(0,4)
  262. }).catch(error => {
  263. this.$refs.uTips.show({
  264. title: error.message,
  265. type: 'warning',
  266. })
  267. })
  268. },
  269. // 获取团队简报
  270. async getTeamPaper() {
  271. let res = await NET.request(API.teamStatistics, { flag: this.flag }, 'POST')
  272. if(res.status == 10000) {
  273. const result = res.data
  274. this.bulletinInfo[0].num = result.nearCreateCustomer
  275. this.bulletinInfo[1].num = result.nearCreateClue
  276. this.bulletinInfo[2].num = result.nearCreateChance
  277. } else {
  278. this.$refs.uTips.show({
  279. title: res.message,
  280. type: 'warning',
  281. })
  282. }
  283. },
  284. // 获取线索状态
  285. async getClueRait() {
  286. let res = await NET.request(API.clueRait, { flag: this.flag }, 'POST')
  287. if(res.status == 10000) {
  288. // 线索
  289. this.threadList = res.data.map(item => {
  290. return {
  291. 'name': `${item.name}(${item.value})` ,
  292. 'value': item.value
  293. }
  294. })
  295. // 线索量
  296. this.threadNum = res.data.reduce((sum,item) => sum += item.value, 0 )
  297. } else {
  298. this.$refs.uTips.show({
  299. title: res.message,
  300. type: 'warning',
  301. })
  302. }
  303. let aaa = {
  304. series: [
  305. {
  306. data: this.threadList
  307. }
  308. ]
  309. };
  310. this.drawCharts('chartBox', aaa);
  311. },
  312. // 切换简报
  313. handlebulletinClick(index) {
  314. this.bulletinCurrent = index
  315. if(!index) {
  316. this.flag = true
  317. } else {
  318. this.flag = false
  319. }
  320. this.getTeamPaper()
  321. this.getClueRait()
  322. },
  323. // 跳转今日新增
  324. goToTodayEnroll() {
  325. uni.navigateTo({
  326. url: '/pagesEnroll/todayEnroll'
  327. });
  328. },
  329. // 跳转所有场馆
  330. goToVenueList() {
  331. uni.navigateTo({
  332. url: '/pagesEnroll/venueList'
  333. });
  334. },
  335. // 跳转场馆详情
  336. goToVenueDetail(item) {
  337. uni.navigateTo({
  338. url: '/pagesEnroll/venueDetail?id=' + item.id
  339. });
  340. },
  341. // 跳转添加信息
  342. goToAddForm(path) {
  343. uni.removeStorageSync('defaultClass');
  344. uni.navigateTo({
  345. url: '/pagesEnroll/' + path
  346. });
  347. },
  348. },
  349. }
  350. </script>
  351. <style lang="scss" scoped>
  352. @import "@/static/css/themes.scss";
  353. .content {
  354. width: 100%;
  355. float: left;
  356. background-color: #f5f6f8;
  357. .swiper-item {
  358. width: 100%;
  359. height: calc(100vh - 50px);
  360. position: relative;
  361. }
  362. .chart-box {
  363. width: 100%;
  364. // height: 240px;
  365. float: left;
  366. padding: 10px 0;
  367. .navbar-list {
  368. display: flex;
  369. justify-content: space-between;
  370. width:100%;
  371. }
  372. .bulletin-list {
  373. display:flex;
  374. align-items: center;
  375. justify-content: space-between;
  376. margin-top: 20rpx;
  377. }
  378. .bulletin-info {
  379. display: flex;
  380. justify-content: space-between;
  381. align-items: center;
  382. .bulletin-item {
  383. flex:1;display: flex;
  384. flex-direction:column;
  385. justify-content: center;
  386. align-items: center;
  387. .bulletin-num {
  388. font-size: 18px;
  389. font-weight: bold;
  390. margin-top: 10rpx;
  391. }
  392. }
  393. }
  394. .chart-canvas {
  395. width: 100%;
  396. height: 500rpx;
  397. }
  398. }
  399. .section-title {
  400. width: 100%;
  401. // height: 28px;
  402. display: flex;
  403. align-items: center;
  404. u-section {
  405. margin-left: 10px;
  406. flex: 1;
  407. }
  408. }
  409. .class-show-box {
  410. width: calc(100% + 32px);
  411. margin: 0 -16px;
  412. float: left;
  413. // padding-bottom: 50px;
  414. .class-show-card {
  415. width: calc(50% - 16px);
  416. margin: 0 8px 16px 8px;
  417. float: left;
  418. .class-show-name {
  419. width: 100%;
  420. text-align: center;
  421. line-height: 18px;
  422. font-size: 12px;
  423. margin-top: 5px;
  424. }
  425. }
  426. }
  427. .enroll-fix-box {
  428. width: 100%;
  429. height: 90px;
  430. position: absolute;
  431. bottom: 40px;
  432. left: 0;
  433. display: flex;
  434. justify-content: space-around;
  435. .enroll-button {
  436. width: 60px;
  437. height: 90px;
  438. .enroll-img {
  439. width: 60px;
  440. height: 60px;
  441. padding-left: 5px;
  442. border-radius: 50%;
  443. background-color: #ffffff;
  444. box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.2);
  445. display: flex;
  446. justify-content: center;
  447. align-items: center;
  448. }
  449. .enroll-text {
  450. width: 60px;
  451. height: 20px;
  452. margin-top: 10px;
  453. line-height: 20px;
  454. font-size: 14px;
  455. text-align: center;
  456. white-space: nowrap;
  457. }
  458. }
  459. }
  460. .user-info {
  461. width: 100%;
  462. height: 110px;
  463. margin-bottom: 20px;
  464. float: left;
  465. background-color: $mainColor;
  466. .user-data {
  467. width: calc(100% - 110px);
  468. height: 110px;
  469. padding: 15px 0 15px 15px;
  470. float: left;
  471. .user-name {
  472. width: 100%;
  473. float: left;
  474. font-size: 24px;
  475. color: #FFFFFF;
  476. line-height: 30px;
  477. margin: 10px 0;
  478. white-space: nowrap;
  479. overflow: hidden;
  480. text-overflow: ellipsis;
  481. }
  482. .user-phone {
  483. width: 100%;
  484. color: #FFFFFF;
  485. line-height: 20px;
  486. float: left;
  487. white-space: nowrap;
  488. overflow: hidden;
  489. text-overflow: ellipsis;
  490. }
  491. }
  492. .user-img {
  493. width: 110px;
  494. height: 110px;
  495. padding: 15px;
  496. float: left;
  497. display: flex;
  498. align-items: center;
  499. justify-content: center;
  500. }
  501. }
  502. .user-handle {
  503. width: 100vw;
  504. height: 40px;
  505. float: left;
  506. padding: 0 15px;
  507. margin-bottom: 10px;
  508. display: flex;
  509. align-items: center;
  510. .handle-icon {
  511. width: 40px;
  512. height: 40px;
  513. text-align: center;
  514. line-height: 40px;
  515. display: flex;
  516. align-items: center;
  517. }
  518. .handle-label {
  519. height: 40px;
  520. flex: 1;
  521. margin-left: 10px;
  522. line-height: 40px;
  523. font-size: 15px;
  524. }
  525. .handle-arrow {
  526. line-height: 40px;
  527. }
  528. }
  529. }
  530. </style>