index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. <template>
  2. <view class="container">
  3. <!-- 轮播图 start -->
  4. <view class="swiper-wrap">
  5. <swiper class="top-swiper" autoplay="true" duration="400" interval="5000" @change="swiperChange"
  6. indicator-dots indicator-active-color="#fff" indicator-color="rgba(255,255,255,0.8)">
  7. <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item"
  8. @click="bannerNavToUrl(item.url)">
  9. <image :src="item.pic" />
  10. </swiper-item>
  11. </swiper>
  12. </view>
  13. <!-- 轮播图 end -->
  14. <!-- 工具箱 start -->
  15. <view class="tool-box flex">
  16. <view class="tool-item" @click="navto('/pages/user/myjslis')">
  17. <image src="../../static/img/t1.png" mode="widthFix"></image>
  18. </view>
  19. <button open-type="contact" class="tool-item" plain="true">
  20. <image src="../../static/img/t2.png" mode="widthFix"></image>
  21. </button>
  22. <view class="tool-item" @click="navto('/pages/index/zngs?type=0')">
  23. <image src="../../static/img/t4.png" mode="widthFix"></image>
  24. </view>
  25. <view class="tool-item" @click="navto('/pages/index/zngs?type=1')">
  26. <image src="../../static/img/t3.png" mode="widthFix"></image>
  27. </view>
  28. </view>
  29. <!-- 工具箱 end -->
  30. <!-- tip start -->
  31. <!-- <view class="tip">
  32. <image src="../../static/img/tip.png" mode="widthFix"></image>
  33. <view class="tip-tit">
  34. <view class="">
  35. 系统使用说明
  36. </view>
  37. <view class="tit-tit">
  38. 计算系统使用教程小贴士
  39. </view>
  40. </view>
  41. </view> -->
  42. <!-- <image src="../../static/img/gbc.png" mode="widthFix" class="gcb"></image> -->
  43. <view class="gcb">
  44. <view class="line flex" >
  45. <view class="line-item" style="background-color: #e7eaf0;font-weight: bold;border-radius: 20rpx 0 0 0;">
  46. 正常公差
  47. </view>
  48. <view class="line-jg" style="background-color: #fefefe;">
  49. </view>
  50. <view class="line-item" style="background-color: #e7eaf0;font-weight: bold;border-radius: 0 20rpx 0 0;">
  51. 大公差
  52. </view>
  53. </view>
  54. <view class="line flex" v-for="gcbitem in gbc">
  55. <view class="line-item line-item-left">
  56. {{gcbitem.zcgc || ''}}
  57. </view>
  58. <view class="line-jg">
  59. </view>
  60. <view class="line-item line-item-right">
  61. {{gcbitem.dgc || ''}}
  62. </view>
  63. </view>
  64. </view>
  65. <view class="" style="height: 47rpx;">
  66. </view>
  67. <!-- tip end -->
  68. </view>
  69. </template>
  70. <script>
  71. import {
  72. saveUrl,
  73. interceptor
  74. } from '@/utils/loginUtils.js';
  75. import {
  76. loadIndexs,
  77. getGcb
  78. } from '@/api/index.js';
  79. import {
  80. getUserInfo
  81. } from '@/api/user.js';
  82. import {
  83. mapState
  84. } from 'vuex';
  85. export default {
  86. data() {
  87. return {
  88. shareShow: false, //分享海报
  89. pageProportion: 0, //保存页面基于750宽度的比例
  90. swiperHeight: 0,
  91. checkid: 0,
  92. titleNViewBackground: '',
  93. swiperCurrent: 0,
  94. swiperLength: 0,
  95. carouselList: [], //轮播列表
  96. page: 1,
  97. limit: 5,
  98. text: '',
  99. gbc: []
  100. };
  101. },
  102. computed: {
  103. ...mapState(['loginInterceptor']),
  104. ...mapState('user', ['hasLogin', 'userInfo'])
  105. },
  106. onLoad: function(option) {
  107. // #ifndef MP
  108. if (option.spread) {
  109. // 存储其他邀请人
  110. uni.setStorageSync('spread', option.spread);
  111. }
  112. // #endif
  113. // #ifdef MP
  114. if (option.scene) {
  115. // 存储小程序邀请人
  116. uni.setStorage({
  117. key: 'spread_code',
  118. data: option.scene
  119. });
  120. }
  121. // #endif
  122. },
  123. onShow: function() {
  124. // 判断是否强制登录
  125. if (this.loginInterceptor && !this.hasLogin) {
  126. // 登录拦截
  127. interceptor();
  128. }
  129. this.loadData();
  130. this.getGcb()
  131. },
  132. //下拉刷新
  133. onPullDownRefresh() {
  134. this.loadData();
  135. },
  136. onShareAppMessage(options) {
  137. // 设置菜单中的转发按钮触发转发事件时的转发内容
  138. let pages = getCurrentPages(); //获取加载的页面
  139. let currentPage = pages[pages.length - 1]; //获取当前页面的对象
  140. let url = currentPage.route; //当前页面url
  141. let item = currentPage.options; //如果要获取url中所带的参数可以查看options
  142. let shareObj = {
  143. title: '水箱计算', // 默认是小程序的名称(可以写slogan等)
  144. path: url, // 默认是当前页面,必须是以‘/’开头的完整路径
  145. imageUrl: '',
  146. success: function(res) {
  147. // 转发成功之后的回调
  148. if (res.errMsg == 'shareAppMessage:ok') {}
  149. },
  150. fail: function() {
  151. // 转发失败之后的回调
  152. if (res.errMsg == 'shareAppMessage:fail cancel') {
  153. // 用户取消转发
  154. } else if (res.errMsg == 'shareAppMessage:fail') {
  155. // 转发失败,其中 detail message 为详细失败信息
  156. }
  157. }
  158. };
  159. return shareObj;
  160. },
  161. methods: {
  162. getGcb() {
  163. getGcb().then(res => {
  164. console.log(res,'gcb++++')
  165. let zcgc = res.data.zcgc
  166. let dgc = res.data.dgc
  167. let arr = []
  168. for(let i = 0;i< dgc.length;i++) {
  169. arr.push({
  170. 'zcgc': zcgc[i],
  171. 'dgc': dgc[i]
  172. })
  173. }
  174. this.gbc = arr
  175. console.log(arr,'arr++++')
  176. })
  177. },
  178. // 打开客服
  179. openKf() {
  180. this.$refs.popupkf.open();
  181. },
  182. // 关闭客服
  183. cancel() {
  184. this.$refs.popupkf.close();
  185. },
  186. navto(url) {
  187. if (!this.hasLogin) {
  188. // 保存地址
  189. saveUrl();
  190. // 登录拦截
  191. interceptor();
  192. } else {
  193. uni.navigateTo({
  194. url,
  195. fail() {
  196. uni.switchTab({
  197. url
  198. })
  199. }
  200. });
  201. }
  202. },
  203. swiperChange() {
  204. },
  205. bannerNavToUrl(url) {
  206. uni.navigateTo({
  207. url,
  208. fail() {
  209. uni.switchTab({
  210. url
  211. })
  212. }
  213. })
  214. },
  215. // 请求载入数据
  216. async loadData() {
  217. loadIndexs({})
  218. .then(({
  219. data
  220. }) => {
  221. let goods = data.info;
  222. this.carouselList = data.banner;
  223. this.swiperLength = this.carouselList.length;
  224. uni.stopPullDownRefresh();
  225. })
  226. .catch(e => {
  227. uni.stopPullDownRefresh();
  228. });
  229. },
  230. // 复制客服微信
  231. comfirm(text) {
  232. console.log(text);
  233. const result = this.uniCopy(text);
  234. if (result === false) {
  235. uni.showToast({
  236. title: '不支持'
  237. });
  238. } else {
  239. uni.showToast({
  240. title: '复制成功',
  241. icon: 'none'
  242. });
  243. }
  244. this.$refs.popupkf.close();
  245. },
  246. uniCopy(content) {
  247. /**
  248. * 小程序端 和 app端的复制逻辑
  249. */
  250. //#ifndef H5
  251. uni.setClipboardData({
  252. data: content,
  253. success: function() {
  254. console.log('success');
  255. return true;
  256. }
  257. });
  258. //#endif
  259. /**
  260. * H5端的复制逻辑
  261. */
  262. // #ifdef H5
  263. if (!document.queryCommandSupported('copy')) {
  264. //为了兼容有些浏览器 queryCommandSupported 的判断
  265. // 不支持
  266. return false;
  267. }
  268. let textarea = document.createElement('textarea');
  269. textarea.value = content;
  270. textarea.readOnly = 'readOnly';
  271. document.body.appendChild(textarea);
  272. textarea.select(); // 选择对象
  273. textarea.setSelectionRange(0, content.length); //核心
  274. let result = document.execCommand('copy'); // 执行浏览器复制命令
  275. textarea.remove();
  276. return result;
  277. // #endif
  278. },
  279. }
  280. };
  281. </script>
  282. <style lang="scss">
  283. page {
  284. background-color: #fff;
  285. height: auto;
  286. min-height: 100%;
  287. }
  288. // 顶部轮播图
  289. .swiper-wrap {
  290. width: 750rpx;
  291. .top-swiper {
  292. width: 750rpx;
  293. height: 375rpx;
  294. margin: auto;
  295. image {
  296. width: 750rpx;
  297. height: 375rpx;
  298. }
  299. }
  300. }
  301. // 工具箱
  302. .tool-box {
  303. width: 700rpx;
  304. margin: 20rpx auto 5rpx;
  305. justify-content: space-between;
  306. flex-wrap: wrap;
  307. font-size: 0;
  308. .tool-item {
  309. padding: 0;
  310. margin: 0;
  311. width: 344rpx;
  312. height: 180rpx;
  313. border: none;
  314. display: inline-block;
  315. margin-bottom: 15rpx;
  316. image {
  317. width: 344rpx;
  318. }
  319. }
  320. }
  321. .tip {
  322. width: 702rpx;
  323. height: 164rpx;
  324. position: relative;
  325. margin: auto;
  326. image {
  327. width: 702rpx;
  328. }
  329. .tip-tit {
  330. height: 164rpx;
  331. position: absolute;
  332. top: 0;
  333. font-size: 32rpx;
  334. font-weight: bold;
  335. color: #333333;
  336. display: flex;
  337. justify-content: center;
  338. flex-direction: column;
  339. padding-left: 140rpx;
  340. .tit-tit {
  341. margin-top: 15rpx;
  342. font-size: 20rpx;
  343. font-weight: 500;
  344. color: #666666;
  345. }
  346. }
  347. }
  348. .popup-box {
  349. width: 522rpx;
  350. height: 605rpx;
  351. background-color: #ffffff;
  352. border-radius: 20rpx;
  353. position: relative;
  354. .img {
  355. position: relative;
  356. top: -56rpx;
  357. left: 0;
  358. width: 522rpx;
  359. height: 132rpx;
  360. display: flex;
  361. justify-content: center;
  362. image {
  363. border-radius: 20rpx 20rpx 0 0;
  364. width: 450rpx;
  365. height: 132rpx;
  366. }
  367. }
  368. .mian {
  369. margin-top: -44rpx;
  370. display: flex;
  371. flex-direction: column;
  372. align-items: center;
  373. // padding: 32rpx 32rpx;
  374. background-color: #ffffff;
  375. border-radius: 0 0 20rpx 20rpx;
  376. text-align: center;
  377. .delivery {
  378. font-size: 40rpx;
  379. color: #333333;
  380. display: flex;
  381. align-items: center;
  382. flex-direction: column;
  383. image {
  384. margin-top: 48rpx;
  385. width: 172rpx;
  386. height: 160rpx;
  387. }
  388. }
  389. .nocancel {
  390. font-size: 32rpx;
  391. color: #333333;
  392. margin-top: 14rpx;
  393. }
  394. .comfirm-box {
  395. margin-top: 52rpx;
  396. display: flex;
  397. // margin-bottom: 32rpx;
  398. // justify-content: space-around;
  399. .cancel {
  400. display: flex;
  401. align-items: center;
  402. justify-content: center;
  403. width: 197rpx;
  404. height: 74rpx;
  405. border: 1px solid #dcc786;
  406. border-radius: 38rpx;
  407. font-size: 32rpx;
  408. color: #605128;
  409. }
  410. .comfirm {
  411. margin-left: 32rpx;
  412. display: flex;
  413. align-items: center;
  414. justify-content: center;
  415. width: 197rpx;
  416. height: 74rpx;
  417. background: linear-gradient(-90deg, #d1ba77 0%, #f7e8ad 100%);
  418. border-radius: 38px;
  419. font-size: 32rpx;
  420. color: #605128;
  421. }
  422. }
  423. }
  424. }
  425. // .gcb {
  426. // display: block;
  427. // margin: 20rpx auto 0;
  428. // width: 700rpx;
  429. // border-radius: 20rpx;
  430. // }
  431. .gcb {
  432. width: 702rpx;
  433. margin: auto;
  434. border-radius: 20rpx;
  435. .line {
  436. height: 97rpx;
  437. line-height: 97rpx;
  438. justify-content: center;
  439. .line-item {
  440. width: 49%;
  441. flex-grow: 1;
  442. background-color: #f7f8fa;
  443. text-align: center;
  444. flex-shrink: 0;
  445. font-size: 28rpx;
  446. }
  447. .line-jg {
  448. background-color: #e9e9e9;
  449. width:1px;
  450. height: 97rpx;
  451. }
  452. &:nth-last-child(1) {
  453. .line-item-left {
  454. border-radius: 0 0 20rpx 0;
  455. }
  456. .line-item-right {
  457. border-radius: 0 20rpx 0 0;
  458. }
  459. }
  460. }
  461. }
  462. </style>