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