index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <template>
  2. <view class="content">
  3. <view class="content-top">
  4. <view class="top-banner">
  5. <u-swiper :list="bannerList" class="banner"></u-swiper>
  6. </view>
  7. </view>
  8. <view class="content-bottom">
  9. <!-- 预约 -->
  10. <u-button :custom-style="yuYueBtn" :hair-line="false" @click="gotoYueYu">一键预约</u-button>
  11. <!-- 接单信息 -->
  12. <view class="bottom-new-notice" v-if="orderStatusText">
  13. <view class="notice-content">
  14. <view class="notice-content-item"><span class="t-icon t-icon-home_icon_bells"></span><span class="item-title">最新通知</span></view>
  15. <view class="notice-content-item">骑手<span>{{orderStatusText ? orderStatusText :''}},</span>请耐心等待</view>
  16. <view class="notice-content-item">{{orderTime ? orderTime :''}}</view>
  17. </view>
  18. <view class="notice-static">
  19. <span class="notice-static-text">{{orderStatusText ? orderStatusText :''}}</span>
  20. </view>
  21. </view>
  22. <!-- 回收指引 -->
  23. <view class="bottom-zhiyin" @click="toZY">
  24. <u-image src="/static/houme_bg_guide.png" mode="" height="160"></u-image>
  25. </view>
  26. <!-- 收回统计 -->
  27. <view class="statistics-title">今日上门回收价格</view>
  28. <view class="bottom-statistics" v-if="hasLogin">
  29. <view class="statistics-rubbishType">
  30. <view class="statistics-box">
  31. <view class="rubbishType-type"><span class="t-icon t-icon-home_icon_paper" style="display: inline-block;margin: 0 10upx;"></span>{{rubbishPaperName ? rubbishPaperName :''}}</view>
  32. <view v-for="item in rubbishPaperList" class="rubbishType-item">
  33. <view>{{item.name ? item.name+':' :''}}{{item.customerPrice ? (item.customerPrice/1000).toFixed(2)/1 :0}} 元/kg</view>
  34. </view>
  35. </view>
  36. <view class="statistics-box">
  37. <view class="rubbishType-type"><span class="t-icon t-icon-home_icon_clothing" style="display: inline-block;margin: 0 10upx;"></span>{{rubbishYWName ? rubbishYWName :''}}</view>
  38. <view v-for="item in rubbishYWList" class="rubbishType-item">
  39. <view>{{item.name ? item.name+':' :''}}{{item.customerPrice ? (item.customerPrice/1000).toFixed(2)/1 :0}} 元/kg</view>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="statistics-rubbishType">
  44. <view class="statistics-box">
  45. <view class="rubbishType-type"><span class="t-icon t-icon-home_icon_plastic" style="display: inline-block;margin: 0 10upx;"></span>{{rubbishSLName ? rubbishSLName :''}}</view>
  46. <view v-for="item in rubbishSLList" class="rubbishType-item">
  47. <view>{{item.name ? item.name+':' :''}}{{item.customerPrice ? (item.customerPrice/1000).toFixed(2)/1 :0}} 元/kg</view>
  48. </view>
  49. </view>
  50. <view class="statistics-box">
  51. <view class="rubbishType-type"><span class="t-icon t-icon-home_icon_metal" style="display: inline-block;margin: 0 10upx;"></span>{{rubbishJSName ? rubbishJSName :''}}</view>
  52. <view v-for="item in rubbishJSList" class="rubbishType-item">
  53. <view>{{item.name ? item.name+':' :''}}{{item.customerPrice ? (item.customerPrice/1000).toFixed(2)/1 :0}} 元/kg</view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="nodata" v-if="!hasLogin">
  59. <u-empty :text="noDataText" mode="data"></u-empty>
  60. </view>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. import {getBannerList,geRubbishType,orderStatus} from '@/api/index'
  66. import { checkLogin } from '@/api/login.js'
  67. export default {
  68. components: { },
  69. data() {
  70. return {
  71. yuYueBtn:{
  72. background: "#4F88F7",
  73. borderRadius: "12px",
  74. color:'#fff',
  75. },
  76. hasLogin:false, // 是否登录
  77. noDataText:"", // 未登录提示文字
  78. orderStatusText:'', // 订单状态
  79. orderTime:'', //
  80. bannerList:[],
  81. rubbishPaperName:"",
  82. rubbishSLName:"",
  83. rubbishYWName:"",
  84. rubbishJSName:"",
  85. rubbishPaperList:[],
  86. rubbishSLList:[],
  87. rubbishYWList:[],
  88. rubbishJSList:[]
  89. }
  90. },
  91. onLoad() {
  92. this.pageInit()
  93. },
  94. onUnload() {
  95. },
  96. onShareAppMessage(res) {
  97. },
  98. onShareTimeline(res) {
  99. },
  100. onShow() {
  101. checkLogin().then(res => {
  102. this.hasLogin=res.status==200
  103. if(this.hasLogin){
  104. this.pageInit()
  105. }else{
  106. this.noDataText="您尚未登录或登录已过期,完成登录后可查看数据信息!"
  107. }
  108. })
  109. },
  110. methods: {
  111. pageInit() {
  112. this.getBanner()
  113. this.geRubbishTypeList()
  114. this.getOrderStatus()
  115. this.checkUpdate()
  116. },
  117. // 获取banner图
  118. getBanner(){
  119. getBannerList().then(res=>{
  120. if(res.status==200){
  121. this.bannerList=res.data || []
  122. }
  123. console.log(res,'-----banner')
  124. })
  125. },
  126. // 获取订单状态
  127. getOrderStatus(){
  128. orderStatus().then(res=>{
  129. if(res.status==200){
  130. this.orderStatusText=res.data.orderStatusDictValue
  131. this.orderTime=res.data.createDate
  132. console.log(res,'----------订单状态')
  133. }
  134. })
  135. },
  136. // 获取垃圾分类
  137. geRubbishTypeList(){
  138. geRubbishType().then(res=>{
  139. if(res.status==200){
  140. console.log(res,'---------垃圾类型')
  141. const a= res.data.find(item=>item.code=='PAPER')
  142. const b= res.data.find(item=>item.code=='PLASTIC')
  143. const c= res.data.find(item=>item.code=='CLOTHES')
  144. const d= res.data.find(item=>item.code=='METAL')
  145. this.rubbishPaperList=a.rubbishTypeVOList
  146. this.rubbishSLList=b.rubbishTypeVOList
  147. this.rubbishYWList=c.rubbishTypeVOList
  148. this.rubbishJSList=d.rubbishTypeVOList
  149. this.rubbishPaperName=a.name
  150. this.rubbishSLName=b.name
  151. this.rubbishYWName=c.name
  152. this.rubbishJSName=d.name
  153. }
  154. })
  155. },
  156. gotoYueYu(){
  157. uni.navigateTo({
  158. url: '/pages/index/yuyue'
  159. })
  160. },
  161. // 回收指引
  162. toZY(){
  163. uni.navigateTo({
  164. url: '/pages/index/zhiyin'
  165. })
  166. },
  167. // 检查更新
  168. checkUpdate(){
  169. if (uni.canIUse('getUpdateManager')) {
  170. const updateManager = uni.getUpdateManager()
  171. updateManager.onCheckForUpdate(function (res) {
  172. console.log('onCheckForUpdate====', res)
  173. // 请求完新版本信息的回调
  174. if (res.hasUpdate) {
  175. console.log('res.hasUpdate====')
  176. updateManager.onUpdateReady(function () {
  177. uni.showModal({
  178. title: '更新提示',
  179. content: '新版本已经准备好,是否重启应用?',
  180. success: function (res) {
  181. console.log('success====', res)
  182. // res: {errMsg: "showModal: ok", cancel: false, confirm: true}
  183. if (res.confirm) {
  184. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  185. updateManager.applyUpdate()
  186. }
  187. }
  188. })
  189. })
  190. updateManager.onUpdateFailed(function () {
  191. // 新的版本下载失败
  192. uni.showModal({
  193. title: '已经有新版本了哟~',
  194. content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
  195. })
  196. })
  197. }
  198. })
  199. }
  200. },
  201. // scroll-view到底部加载更多
  202. onreachBottom() {
  203. },
  204. // 总计
  205. getTotal(){
  206. // this.titleStatus = true
  207. // gatherTotal({
  208. // beginDate: this.searchForm.beginDate?moment(this.searchForm.beginDate).format('YYYY-MM-DD 00:00:00'):'',
  209. // endDate: this.searchForm.endDate ? moment(this.searchForm.endDate).format('YYYY-MM-DD 23:59:59'):''}).then(res=>{
  210. // if(res.status==200){
  211. // const a = res.data.find(item=>item.rubbishType=='GATHER_BUILDING')
  212. // const b = res.data.find(item=>item.rubbishType=='GATHER_OTHER')
  213. // const c = res.data.find(item=>item.rubbishType=='GATHER_KITCHEN')
  214. // this.jianzhuTotal= a ? (a.rubbishWeight/1000).toFixed(3)/1 : '0'
  215. // this.chuyuTotal= c ? (c.rubbishWeight/1000).toFixed(3)/1 : '0'
  216. // this.otherTotal= b ? (b.rubbishWeight/1000).toFixed(3)/1 : '0'
  217. // }
  218. // console.log(res)
  219. // this.titleStatus = false
  220. // })
  221. },
  222. // 打开垃圾数据录入页面
  223. intoPage(item) {
  224. // const flag=item ? item.gatherId : ''
  225. // console.log(flag,'---------hangid,;;;;')
  226. // let url = flag ? `/pages/index/addData?id=${flag}` : `/pages/index/addData`
  227. // // uni.navigateTo({
  228. // // url: url
  229. // // })
  230. // if(!this.hasLogin){
  231. // uni.showModal({
  232. // title: '提示',
  233. // content: '您尚未登录或登录已过期,请登录后使用',
  234. // success: (res)=> {
  235. // if (res.confirm) {
  236. // uni.navigateTo({
  237. // url: '/pages/login/login'
  238. // })
  239. // } else if (res.cancel) {
  240. // console.log('用户点击取消');
  241. // }
  242. // }
  243. // });
  244. // } else {
  245. // uni.navigateTo({
  246. // url: url
  247. // })
  248. // }
  249. }
  250. }
  251. }
  252. </script>
  253. <style lang="scss" scoped>
  254. .content {
  255. width: 100%;
  256. height: 100vh;
  257. display: flex;
  258. flex-direction: column;
  259. padding: 0;
  260. .content-top{
  261. width: 100%;
  262. height:260upx ;
  263. background-color: #4F88F7;
  264. border-bottom-left-radius: 50%; /* 左下角 */
  265. border-bottom-right-radius:50%; /* 右下角 */
  266. opacity: 1;
  267. .top-banner{
  268. padding: 20upx 30upx 0;
  269. .banner{
  270. width:100%;
  271. height: 140px;
  272. }
  273. }
  274. }
  275. .content-bottom{
  276. padding: 30upx;
  277. background-color: #f5f5f5;
  278. .bottom-new-notice{
  279. background-image: url('../../static/home_bg_expressage.png');
  280. height:220upx;
  281. margin-top: 30upx;
  282. display: flex;
  283. justify-content: space-between;
  284. align-items: center;
  285. padding: 20upx 30upx;
  286. .notice-content{
  287. .notice-content-item{
  288. margin: 15upx 0;
  289. display: flex;
  290. align-items: center;
  291. .item-title{
  292. display: inline-block;
  293. margin-left: 20upx;
  294. }
  295. }
  296. .notice-content-item:last-child{
  297. font-size: 26upx;
  298. font-family: PingFang SC;
  299. font-weight: 400;
  300. color: #7C7D7E;
  301. }
  302. }
  303. .notice-static{
  304. width:186upx;
  305. height: 108upx;
  306. background-image: url('../../static/home_sign_rider.png');
  307. .notice-static-text{
  308. position: relative;
  309. top:21upx;
  310. left:85upx
  311. }
  312. }
  313. }
  314. .bottom-zhiyin{
  315. margin: 30upx 0;
  316. }
  317. .statistics-title{
  318. font-size: 36upx;
  319. font-family: PingFang SC;
  320. font-weight: bold;
  321. color: #191919;
  322. opacity: 1;
  323. margin-bottom: 30upx;
  324. }
  325. .bottom-statistics{
  326. display: flex;
  327. width: 100%;
  328. justify-content: space-between;
  329. .statistics-rubbishType{
  330. width: 48%;
  331. .statistics-box{
  332. margin-bottom:30upx ;
  333. background-color: #fff;
  334. padding: 20upx;
  335. border-radius:16upx;
  336. }
  337. .statistics-box:last-child{
  338. margin-bottom:0 ;
  339. }
  340. }
  341. .rubbishType-type{
  342. display: flex;
  343. align-items: center;
  344. justify-content: center;
  345. font-size: 28upx;
  346. font-family: PingFang SC;
  347. font-weight: 400;
  348. color: #000000;
  349. }
  350. .rubbishType-item{
  351. display: flex;
  352. justify-content: center;
  353. margin:10upx 0 ;
  354. font-size: 26upx;
  355. font-family: PingFang SC;
  356. font-weight: 400;
  357. color: #444444;
  358. }
  359. }
  360. }
  361. }
  362. </style>