index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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">
  29. <view class="statistics-rubbishType">
  30. <view class="statistics-box" v-if="rubbishPaperList.length">
  31. <view class="rubbishType-type"><span class="t-icon t-icon-home_icon_paper" style="display: inline-block;margin-right:10upx;"></span>{{rubbishPaperName ? rubbishPaperName :''}}</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 :0}} 元/kg</span>
  34. </view>
  35. </view>
  36. <view class="statistics-box" v-if="rubbishYWList.length">
  37. <view class="rubbishType-type"><span class="t-icon t-icon-home_icon_clothing" style="display: inline-block;margin-right: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).toFixed(2)/1 :0}} 元/kg</view>
  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"><span class="t-icon t-icon-home_icon_plastic" style="display: inline-block;margin-right: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).toFixed(2)/1 :0}} 元/kg</view>
  48. </view>
  49. </view>
  50. <view class="statistics-box" v-if="rubbishJSList.length">
  51. <view class="rubbishType-type"><span class="t-icon t-icon-home_icon_metal" style="display: inline-block;margin-right: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).toFixed(2)/1 :0}} 元/kg</view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <!-- <view class="nodata">
  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. if(this.hasLogin){
  158. uni.navigateTo({
  159. url: '/pages/index/yuyue'
  160. })
  161. }else{
  162. this.loginModal()
  163. }
  164. },
  165. // 回收指引
  166. toZY(){
  167. uni.navigateTo({
  168. url: '/pages/index/zhiyin'
  169. })
  170. },
  171. // 未登录弹窗
  172. loginModal(){
  173. uni.showModal({
  174. title: '提示',
  175. content: '您尚未登录或登录已过期,请登录后使用',
  176. success: (res)=> {
  177. if (res.confirm) {
  178. uni.navigateTo({
  179. url: '/pages/login/login'
  180. })
  181. } else if (res.cancel) {
  182. console.log('用户点击取消');
  183. }
  184. }
  185. });
  186. },
  187. // 检查更新
  188. checkUpdate(){
  189. if (uni.canIUse('getUpdateManager')) {
  190. const updateManager = uni.getUpdateManager()
  191. updateManager.onCheckForUpdate(function (res) {
  192. console.log('onCheckForUpdate====', res)
  193. // 请求完新版本信息的回调
  194. if (res.hasUpdate) {
  195. console.log('res.hasUpdate====')
  196. updateManager.onUpdateReady(function () {
  197. uni.showModal({
  198. title: '更新提示',
  199. content: '新版本已经准备好,是否重启应用?',
  200. success: function (res) {
  201. console.log('success====', res)
  202. // res: {errMsg: "showModal: ok", cancel: false, confirm: true}
  203. if (res.confirm) {
  204. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  205. updateManager.applyUpdate()
  206. }
  207. }
  208. })
  209. })
  210. updateManager.onUpdateFailed(function () {
  211. // 新的版本下载失败
  212. uni.showModal({
  213. title: '已经有新版本了哟~',
  214. content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
  215. })
  216. })
  217. }
  218. })
  219. }
  220. },
  221. }
  222. }
  223. </script>
  224. <style lang="scss" scoped>
  225. .content {
  226. width: 100%;
  227. height: 100vh;
  228. display: flex;
  229. flex-direction: column;
  230. padding: 0;
  231. .content-top{
  232. width: 100%;
  233. height:260upx ;
  234. background-color: #4F88F7;
  235. border-bottom-left-radius: 50%; /* 左下角 */
  236. border-bottom-right-radius:50%; /* 右下角 */
  237. opacity: 1;
  238. .top-banner{
  239. padding: 20upx 30upx 0;
  240. .banner{
  241. width:100%;
  242. height: 140px;
  243. }
  244. }
  245. }
  246. .content-bottom{
  247. padding: 30upx;
  248. background-color: #f5f5f5;
  249. .bottom-new-notice{
  250. background-image: url('../../static/home_bg_expressage.png');
  251. height:220upx;
  252. margin-top: 30upx;
  253. display: flex;
  254. justify-content: space-between;
  255. align-items: center;
  256. padding: 20upx 30upx;
  257. .notice-content{
  258. .notice-content-item{
  259. margin: 15upx 0;
  260. display: flex;
  261. align-items: center;
  262. .item-title{
  263. display: inline-block;
  264. margin-left: 20upx;
  265. }
  266. }
  267. .notice-content-item:last-child{
  268. font-size: 26upx;
  269. font-family: PingFang SC;
  270. font-weight: 400;
  271. color: #7C7D7E;
  272. }
  273. }
  274. .notice-static{
  275. width:186upx;
  276. height: 108upx;
  277. background-image: url('../../static/home_sign_rider.png');
  278. .notice-static-text{
  279. position: relative;
  280. top:21upx;
  281. left:85upx
  282. }
  283. }
  284. }
  285. .bottom-zhiyin{
  286. margin: 30upx 0;
  287. }
  288. .statistics-title{
  289. font-size: 36upx;
  290. font-family: PingFang SC;
  291. font-weight: bold;
  292. color: #191919;
  293. opacity: 1;
  294. margin-bottom: 30upx;
  295. }
  296. .bottom-statistics{
  297. display: flex;
  298. width: 100%;
  299. justify-content: space-between;
  300. .statistics-rubbishType{
  301. width: 48%;
  302. .statistics-box{
  303. margin-bottom:30upx ;
  304. background-color: #fff;
  305. padding: 20upx 10upx 20upx 20upx;
  306. border-radius:16upx;
  307. }
  308. .statistics-box:last-child{
  309. margin-bottom:0 ;
  310. }
  311. }
  312. .rubbishType-type{
  313. display: flex;
  314. align-items: center;
  315. justify-content: flex-start;
  316. font-size: 28upx;
  317. font-family: PingFang SC;
  318. font-weight: 400;
  319. color: #000000;
  320. }
  321. .rubbishType-item{
  322. display: flex;
  323. justify-content: flex-start;
  324. margin:10upx 0 ;
  325. font-size: 26upx;
  326. font-family: PingFang SC;
  327. font-weight: 400;
  328. color: #444444;
  329. }
  330. }
  331. }
  332. }
  333. </style>