index.vue 11 KB

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