index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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"><u-icon class="icon" name="home_icon_bells" custom-prefix="custom-icon" size="38" color="#333"></u-icon></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">
  29. <view class="statistics-rubbishType">
  30. <view class="statistics-box" v-if="rubbishPaperList.length">
  31. <view class="rubbishType-type"><u-icon class="icon" name="home_icon_paper" custom-prefix="custom-icon" size="36" color="#333"></u-icon><span style="display:in;ine-block; margin-left:10upx">{{rubbishPaperName ? rubbishPaperName :''}}</span></view>
  32. <view v-for="item in rubbishPaperList" class="rubbishType-item">
  33. <span>{{item.name ? item.name :''}}</span><span>{{item.customerPrice ? ':'+(item.customerPrice).toFixed(2)/1+'元/kg' :''}} </span>
  34. </view>
  35. </view>
  36. <view class="statistics-box" v-if="rubbishYWList.length">
  37. <view class="rubbishType-type"><u-icon class="icon" name="home_icon_clothing" custom-prefix="custom-icon" size="36" color="#333"></u-icon><span style="display:in;ine-block; margin-left:10upx">{{rubbishYWName ? rubbishYWName :''}}</span></view>
  38. <view v-for="item in rubbishYWList" class="rubbishType-item">
  39. <span>{{item.name ? item.name :''}}</span><span>{{item.customerPrice ? ':'+(item.customerPrice).toFixed(2)/1+'元/kg' :''}} </span>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="statistics-rubbishType">
  44. <view class="statistics-box" v-if="rubbishSLList.length">
  45. <view class="rubbishType-type"><u-icon class="icon" name="home_icon_plastic" custom-prefix="custom-icon" size="36" color="#333"></u-icon><span style="display:in;ine-block; margin-left:10upx">{{rubbishSLName ? rubbishSLName :''}}</span></view>
  46. <view v-for="item in rubbishSLList" class="rubbishType-item">
  47. <span>{{item.name ? item.name :''}}</span><span>{{item.customerPrice ? ':'+(item.customerPrice).toFixed(2)/1+'元/kg' :''}} </span>
  48. </view>
  49. </view>
  50. <view class="statistics-box" v-if="rubbishJSList.length">
  51. <view class="rubbishType-type"><u-icon class="icon" name="home_icon_metal" custom-prefix="custom-icon" size="36" color="#333"></u-icon><span style="display:in;ine-block; margin-left:10upx">{{rubbishJSName ? rubbishJSName :''}}</span></view>
  52. <view v-for="item in rubbishJSList" class="rubbishType-item">
  53. <span>{{item.name ? item.name :''}}</span><span>{{item.customerPrice ? ':'+(item.customerPrice).toFixed(2)/1+'元/kg' :''}} </span>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="nodata" v-if="rubbishPriceList.length==0">
  59. <u-empty src="/static/def_result.png" :text="noDataText" icon-size="260" ></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. rubbishPriceList:[]
  90. }
  91. },
  92. onLoad() {
  93. this.pageInit()
  94. },
  95. onUnload() {
  96. },
  97. onShareAppMessage(res) {
  98. },
  99. onShareTimeline(res) {
  100. },
  101. onShow() {
  102. checkLogin().then(res => {
  103. this.hasLogin=res.status==200
  104. if(this.hasLogin){
  105. this.pageInit()
  106. }else{
  107. this.noDataText="您尚未登录或登录已过期,完成登录后可查看数据信息!"
  108. }
  109. })
  110. },
  111. methods: {
  112. pageInit() {
  113. this.getBanner()
  114. this.geRubbishTypeList()
  115. this.getOrderStatus()
  116. this.checkUpdate()
  117. },
  118. // 获取banner图
  119. getBanner(){
  120. getBannerList().then(res=>{
  121. if(res.status==200){
  122. this.bannerList=res.data || []
  123. }
  124. console.log(res,'-----banner')
  125. })
  126. },
  127. // 获取订单状态
  128. getOrderStatus(){
  129. orderStatus().then(res=>{
  130. if(res.status==200){
  131. this.orderStatusText=res.data.orderStatusDictValue
  132. this.orderTime=res.data.createDate
  133. console.log(res,'----------订单状态')
  134. }
  135. })
  136. },
  137. // 获取垃圾分类
  138. geRubbishTypeList(){
  139. geRubbishType().then(res=>{
  140. if(res.status==200){
  141. console.log(res,'---------垃圾类型')
  142. this.rubbishPriceList=res.data
  143. const a= res.data.find(item=>item.code=='PAPER')
  144. const b= res.data.find(item=>item.code=='PLASTIC')
  145. const c= res.data.find(item=>item.code=='CLOTHES')
  146. const d= res.data.find(item=>item.code=='METAL')
  147. this.rubbishPaperList=a.rubbishTypeVOList
  148. this.rubbishSLList=b.rubbishTypeVOList
  149. this.rubbishYWList=c.rubbishTypeVOList
  150. this.rubbishJSList=d.rubbishTypeVOList
  151. this.rubbishPaperName=a.name
  152. this.rubbishSLName=b.name
  153. this.rubbishYWName=c.name
  154. this.rubbishJSName=d.name
  155. }
  156. })
  157. },
  158. gotoYueYu(){
  159. if(this.hasLogin){
  160. uni.navigateTo({
  161. url: '/pages/index/yuyue'
  162. })
  163. }else{
  164. this.loginModal()
  165. }
  166. },
  167. // 回收指引
  168. toZY(){
  169. uni.navigateTo({
  170. url: '/pages/index/zhiyin'
  171. })
  172. },
  173. // 未登录弹窗
  174. loginModal(){
  175. uni.showModal({
  176. title: '提示',
  177. content: '您尚未登录或登录已过期,请登录后使用',
  178. success: (res)=> {
  179. if (res.confirm) {
  180. uni.navigateTo({
  181. url: '/pages/login/login'
  182. })
  183. } else if (res.cancel) {
  184. console.log('用户点击取消');
  185. }
  186. }
  187. });
  188. },
  189. // 检查更新
  190. checkUpdate(){
  191. if (uni.canIUse('getUpdateManager')) {
  192. const updateManager = uni.getUpdateManager()
  193. updateManager.onCheckForUpdate(function (res) {
  194. console.log('onCheckForUpdate====', res)
  195. // 请求完新版本信息的回调
  196. if (res.hasUpdate) {
  197. console.log('res.hasUpdate====')
  198. updateManager.onUpdateReady(function () {
  199. uni.showModal({
  200. title: '更新提示',
  201. content: '新版本已经准备好,是否重启应用?',
  202. success: function (res) {
  203. console.log('success====', res)
  204. // res: {errMsg: "showModal: ok", cancel: false, confirm: true}
  205. if (res.confirm) {
  206. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  207. updateManager.applyUpdate()
  208. }
  209. }
  210. })
  211. })
  212. updateManager.onUpdateFailed(function () {
  213. // 新的版本下载失败
  214. uni.showModal({
  215. title: '已经有新版本了哟~',
  216. content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
  217. })
  218. })
  219. }
  220. })
  221. }
  222. },
  223. }
  224. }
  225. </script>
  226. <style lang="scss" scoped>
  227. .content {
  228. width: 100%;
  229. height: 100vh;
  230. display: flex;
  231. flex-direction: column;
  232. padding: 0;
  233. .content-top{
  234. width: 100%;
  235. height:260upx ;
  236. background-color: #4F88F7;
  237. border-bottom-left-radius: 50%; /* 左下角 */
  238. border-bottom-right-radius:50%; /* 右下角 */
  239. opacity: 1;
  240. .top-banner{
  241. padding: 20upx 30upx 0;
  242. .banner{
  243. width:100%;
  244. height: 140px;
  245. }
  246. }
  247. }
  248. .content-bottom{
  249. padding: 30upx;
  250. background-color: #f5f5f5;
  251. .bottom-new-notice{
  252. background-image: url('../../static/home_bg_expressage.png');
  253. height:220upx;
  254. margin-top: 30upx;
  255. display: flex;
  256. justify-content: space-between;
  257. align-items: center;
  258. padding: 20upx 30upx;
  259. .notice-content{
  260. .notice-content-item{
  261. margin: 15upx 0;
  262. display: flex;
  263. align-items: center;
  264. .item-title{
  265. display: inline-block;
  266. margin-left: 20upx;
  267. }
  268. }
  269. .notice-content-item:last-child{
  270. font-size: 26upx;
  271. font-family: PingFang SC;
  272. font-weight: 400;
  273. color: #7C7D7E;
  274. }
  275. }
  276. .notice-static{
  277. width:186upx;
  278. height: 108upx;
  279. background-image: url('../../static/home_sign_rider.png');
  280. background-size:100% 100%;
  281. .notice-static-text{
  282. position: relative;
  283. top:21upx;
  284. left:85upx
  285. }
  286. }
  287. }
  288. .bottom-zhiyin{
  289. margin: 30upx 0;
  290. }
  291. .statistics-title{
  292. font-size: 36upx;
  293. font-family: PingFang SC;
  294. font-weight: bold;
  295. color: #191919;
  296. opacity: 1;
  297. margin-bottom: 30upx;
  298. }
  299. .bottom-statistics{
  300. display: flex;
  301. width: 100%;
  302. justify-content: space-between;
  303. .statistics-rubbishType{
  304. width: 48%;
  305. .statistics-box{
  306. margin-bottom:30upx ;
  307. background-color: #fff;
  308. padding: 20upx 10upx 20upx 20upx;
  309. border-radius:16upx;
  310. }
  311. .statistics-box:last-child{
  312. margin-bottom:0 ;
  313. }
  314. }
  315. .rubbishType-type{
  316. display: flex;
  317. align-items: center;
  318. justify-content: flex-start;
  319. font-size: 28upx;
  320. font-family: PingFang SC;
  321. font-weight: 400;
  322. color: #000000;
  323. }
  324. .rubbishType-item{
  325. display: flex;
  326. justify-content: flex-start;
  327. margin:10upx 0 ;
  328. font-size: 26upx;
  329. font-family: PingFang SC;
  330. font-weight: 400;
  331. color: #444444;
  332. }
  333. }
  334. }
  335. }
  336. </style>