index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  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. <view class="bottom-new-notice" v-if="orderTime" @click="checkOrderDetail()">
  11. <view class="notice-content">
  12. <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">您于{{orderTime ? orderTime :''}}下单成功,点击查看详情</span></view>
  13. <view class="notice-content-item"></view>
  14. </view>
  15. </view>
  16. <!-- 下单 -->
  17. <view class="bottom-order flex justify_between align_center">
  18. <view class="order-type flex flex_column justify_center" @click="gotoSaoMa">
  19. <u-image src="/static/index/home_icon_code.png" width="186rpx" height="144rpx"></u-image>
  20. <view class="type type-saoma">扫码下单</view>
  21. <view class="type-info">在线下单</view>
  22. </view>
  23. <view class="order-type flex flex_column justify_center" @click="gotoYueYu">
  24. <u-image src="/static/index/home_icon.png" width="176rpx" height="164rpx"></u-image>
  25. <view class="type">自主下单</view>
  26. <view class="type-info">免费上门回收</view>
  27. </view>
  28. </view>
  29. <!-- 收回统计 -->
  30. <view class="statistics-title">今日上门回收价格</view>
  31. <view>
  32. <!-- 纸张类 -->
  33. <view class="statistics-box" v-if="rubbishPaperList.length">
  34. <view class="rubbishType-type">
  35. {{rubbishPaperName ? rubbishPaperName :''}}
  36. </view>
  37. <view class="flex rubbish">
  38. <view v-for="item in rubbishPaperList" class="rubbishType-item">
  39. <u-image :src="item.image" width="92" height="92"></u-image>
  40. <span>{{item.name ? item.name :''}}</span><span>{{item.customerPrice ? (item.customerPrice).toFixed(2)/1+'元/kg' :''}} </span>
  41. </view>
  42. </view>
  43. </view>
  44. <!-- 塑料类 -->
  45. <view class="statistics-box" v-if="rubbishSLList.length">
  46. <view class="rubbishType-type">
  47. {{rubbishSLName ? rubbishSLName :''}}
  48. </view>
  49. <view class="flex rubbish">
  50. <view v-for="item in rubbishSLList" class="rubbishType-item">
  51. <u-image :src="item.image" width="92" height="92"></u-image>
  52. <span>{{item.name ? item.name :''}}</span><span>{{item.customerPrice ? (item.customerPrice).toFixed(2)/1+'元/kg' :''}} </span>
  53. </view>
  54. </view>
  55. </view>
  56. <!-- 金属类 -->
  57. <view class="statistics-box" v-if="rubbishJSList.length">
  58. <view class="rubbishType-type">
  59. {{rubbishJSName ? rubbishJSName :''}}
  60. </view>
  61. <view class="flex rubbish">
  62. <view v-for="item in rubbishJSList" class="rubbishType-item">
  63. <u-image :src="item.image" width="92" height="92"></u-image>
  64. <span>{{item.name ? item.name :''}}</span><span>{{item.customerPrice ? (item.customerPrice).toFixed(2)/1+'元/kg' :''}} </span>
  65. </view>
  66. </view>
  67. </view>
  68. <!-- 衣物类 -->
  69. <view class="statistics-box" v-if="rubbishYWList.length">
  70. <view class="rubbishType-type">
  71. {{rubbishYWName ? rubbishYWName :''}}
  72. </view>
  73. <view class="flex rubbish">
  74. <view v-for="item in rubbishYWList" class="rubbishType-item">
  75. <u-image :src="item.image" width="92" height="92"></u-image>
  76. <span>{{item.name ? item.name :''}}</span><span>{{item.customerPrice ? (item.customerPrice).toFixed(2)/1+'元/kg' :''}} </span>
  77. </view>
  78. </view>
  79. </view>
  80. <view class="nodata" v-if="rubbishPriceList.length==0">
  81. <u-empty src="/static/def_result.png" :text="noDataText" icon-size="260" ></u-empty>
  82. </view>
  83. </view>
  84. </view>
  85. </view>
  86. </template>
  87. <script>
  88. import {getBannerList,geRubbishType,orderStatus} from '@/api/index'
  89. import { checkLogin } from '@/api/login.js'
  90. export default {
  91. components: { },
  92. data() {
  93. return {
  94. yuYueBtn:{
  95. background: "#4F88F7",
  96. borderRadius: "12px",
  97. color:'#fff',
  98. },
  99. hasLogin:false, // 是否登录
  100. noDataText:"", // 未登录提示文字
  101. orderTime:'', // 创建时间
  102. bannerList:[],
  103. rubbishPaperName:"",
  104. rubbishSLName:"",
  105. rubbishYWName:"",
  106. rubbishJSName:"",
  107. rubbishPaperList:[],
  108. rubbishSLList:[],
  109. rubbishYWList:[],
  110. rubbishJSList:[],
  111. rubbishPriceList:[],
  112. orderId:'' // 订单id
  113. }
  114. },
  115. onLoad() {
  116. this.geRubbishTypeList()
  117. this.pageInit()
  118. },
  119. onUnload() {
  120. },
  121. onShareAppMessage(res) {
  122. },
  123. onShareTimeline(res) {
  124. },
  125. onShow() {
  126. this.geRubbishTypeList()
  127. checkLogin().then(res => {
  128. this.hasLogin=res.status==200
  129. if(this.hasLogin){
  130. this.pageInit()
  131. }else{
  132. this.noDataText="您尚未登录或登录已过期,完成登录后可查看数据信息!"
  133. }
  134. })
  135. },
  136. methods: {
  137. pageInit() {
  138. this.orderTime=''
  139. this.getBanner()
  140. this.getOrderStatus()
  141. this.checkUpdate()
  142. },
  143. // 获取banner图
  144. getBanner(){
  145. getBannerList().then(res=>{
  146. if(res.status==200){
  147. this.bannerList=res.data || []
  148. }
  149. })
  150. },
  151. // 获取订单状态
  152. getOrderStatus(){
  153. orderStatus().then(res=>{
  154. if(res.status==200){
  155. this.orderId=res.data.id
  156. this.orderTime=res.data.createDate
  157. }
  158. })
  159. },
  160. // 查看订单详情
  161. checkOrderDetail(){
  162. uni.navigateTo({
  163. url:`/pages/order/orderDetails?id=${this.orderId}`
  164. })
  165. },
  166. // 获取垃圾分类
  167. geRubbishTypeList(){
  168. geRubbishType().then(res=>{
  169. if(res.status==200){
  170. this.rubbishPriceList=res.data
  171. const a= res.data.find(item=>item.code=='PAPER')
  172. const b= res.data.find(item=>item.code=='PLASTIC')
  173. const c= res.data.find(item=>item.code=='CLOTHES')
  174. const d= res.data.find(item=>item.code=='METAL')
  175. /* 纸张类 */
  176. this.rubbishPaperList=a.rubbishTypeVOList
  177. this.rubbishPaperList.map(item=>{
  178. if(item.code=='YELLOW_PAPER'){
  179. item.image='/static/index/icon_aper_yellow.png'
  180. }
  181. if(item.code=='COLOUR_PAPER'){
  182. item.image='/static/index/icon_aper_flower.png'
  183. }
  184. if(item.code=='BOOK_PAPER'){
  185. item.image='/static/index/icon_book.png'
  186. }
  187. if(item.code=='MAGAZINE'){
  188. item.image='/static/index/icon_magazine.png'
  189. }
  190. if(item.code=='OTHER_PAPER'){
  191. item.image='/static/index/icon_aper_miscellaneous.png'
  192. }
  193. if(item.code=='NEWS_PAPER'){
  194. item.image='/static/index/icon_newspaper.png'
  195. }
  196. })
  197. // 塑料类
  198. this.rubbishSLList=b.rubbishTypeVOList
  199. this.rubbishSLList.map(item=>{
  200. if(item.code=='PLASTIC_WHITE'){
  201. item.image='/static/index/icon_frame_white.png'
  202. }
  203. if(item.code=='PLASTIC_BLACK'){
  204. item.image='/static/index/icon_frame_black.png'
  205. }
  206. if(item.code=='PMMA'){
  207. item.image='/static/index/icon_acrylic.png'
  208. }
  209. if(item.code=='PLASTIC_LUCENCY'){
  210. item.image='/static/index/icon_bottle.png'
  211. }
  212. })
  213. // 衣物
  214. this.rubbishYWList=c.rubbishTypeVOList
  215. this.rubbishYWList.map(item=>{
  216. if(item.code=='SIMPLE_CLOTHES'){
  217. item.image='/static/index/icon_clothes.png'
  218. }
  219. })
  220. // 金属
  221. this.rubbishJSList=d.rubbishTypeVOList
  222. this.rubbishJSList.map(item=>{
  223. if(item.code=='THIN_IRON'){
  224. item.image='/static/index/icon_iron_thin.png'
  225. }
  226. if(item.code=='THICK_IRON'){
  227. item.image='/static/index/icon_iron_thick.png'
  228. }
  229. if(item.code=='STAINLESS_IRON'){
  230. item.image='/static/index/icon_steel.png'
  231. }
  232. })
  233. this.rubbishPaperName=a.name
  234. this.rubbishSLName=b.name
  235. this.rubbishYWName=c.name
  236. this.rubbishJSName=d.name
  237. }
  238. })
  239. },
  240. // 扫码下单
  241. gotoSaoMa(){
  242. if(this.hasLogin){
  243. wx.scanCode({
  244. success: (res)=> {
  245. uni.navigateTo({
  246. url: '/pages/index/order'
  247. })
  248. }
  249. })
  250. }else{
  251. this.loginModal()
  252. }
  253. },
  254. // 自主下单
  255. gotoYueYu(){
  256. if(this.hasLogin){
  257. uni.navigateTo({
  258. url: '/pages/index/order'
  259. })
  260. }else{
  261. this.loginModal()
  262. }
  263. },
  264. // 未登录弹窗
  265. loginModal(){
  266. uni.showModal({
  267. title: '提示',
  268. content: '您尚未登录或登录已过期,请登录后使用',
  269. success: (res)=> {
  270. if (res.confirm) {
  271. uni.navigateTo({
  272. url: '/pages/login/login'
  273. })
  274. } else if (res.cancel) {
  275. console.log('用户点击取消');
  276. }
  277. }
  278. });
  279. },
  280. // 检查更新
  281. checkUpdate(){
  282. if (uni.canIUse('getUpdateManager')) {
  283. const updateManager = uni.getUpdateManager()
  284. updateManager.onCheckForUpdate(function (res) {
  285. console.log('onCheckForUpdate====', res)
  286. // 请求完新版本信息的回调
  287. if (res.hasUpdate) {
  288. console.log('res.hasUpdate====')
  289. updateManager.onUpdateReady(function () {
  290. uni.showModal({
  291. title: '更新提示',
  292. content: '新版本已经准备好,是否重启应用?',
  293. success: function (res) {
  294. console.log('success====', res)
  295. // res: {errMsg: "showModal: ok", cancel: false, confirm: true}
  296. if (res.confirm) {
  297. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  298. updateManager.applyUpdate()
  299. }
  300. }
  301. })
  302. })
  303. updateManager.onUpdateFailed(function () {
  304. // 新的版本下载失败
  305. uni.showModal({
  306. title: '已经有新版本了哟~',
  307. content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
  308. })
  309. })
  310. }
  311. })
  312. }
  313. },
  314. }
  315. }
  316. </script>
  317. <style lang="scss" scoped>
  318. .content {
  319. width: 100%;
  320. height: 100vh;
  321. display: flex;
  322. flex-direction: column;
  323. padding: 0;
  324. .content-top{
  325. .top-banner{
  326. padding: 20upx 30upx 0;
  327. .banner{
  328. width:100%;
  329. height: 140px;
  330. }
  331. }
  332. }
  333. .content-bottom{
  334. padding: 0 30upx 30upx;
  335. background-color: #f5f5f5;
  336. .bottom-new-notice{
  337. background-image: url('../../static/home_bg_expressage.png');
  338. background-size: 100% 100%;
  339. height:220upx;
  340. margin-top: 30upx;
  341. display: flex;
  342. justify-content: space-between;
  343. align-items: center;
  344. padding: 20upx 30upx;
  345. .notice-content{
  346. .notice-content-item{
  347. margin: 15upx 0;
  348. display: flex;
  349. align-items: center;
  350. .item-title{
  351. display: inline-block;
  352. margin-left: 20upx;
  353. }
  354. }
  355. .notice-content-item:last-child{
  356. font-size: 26upx;
  357. font-family: PingFang SC;
  358. font-weight: 400;
  359. color: #7C7D7E;
  360. }
  361. }
  362. .notice-static{
  363. width:186upx;
  364. height: 108upx;
  365. background-image: url('../../static/home_sign_rider.png');
  366. background-size:100% 100%;
  367. .notice-static-text{
  368. position: relative;
  369. top:21upx;
  370. left:85upx
  371. }
  372. }
  373. }
  374. .bottom-zhiyin{
  375. margin: 30upx 0;
  376. }
  377. .bottom-order{
  378. padding: 50upx 86upx;
  379. margin:30upx 0 56upx;
  380. background: #FFFFFF;
  381. box-shadow: 0px 18px 35px rgba(1, 136, 209, 0.1);
  382. opacity: 1;
  383. border-radius: 12px;
  384. .order-type{
  385. text-align: center;
  386. .type{
  387. font-size: 42upx;
  388. font-weight: bold;
  389. color: #000000;
  390. margin-top: 10upx;
  391. }
  392. .type-saoma{
  393. margin-top: 35upx;
  394. }
  395. .type-info{
  396. color:#999999;
  397. font-size: 24upx;
  398. font-weight: 400;
  399. margin-top: 10upx;
  400. }
  401. }
  402. }
  403. .statistics-title{
  404. font-size: 36upx;
  405. font-family: PingFang SC;
  406. font-weight: bold;
  407. color: #191919;
  408. opacity: 1;
  409. margin-bottom: 30upx;
  410. }
  411. .statistics-box{
  412. padding: 20upx 30upx;
  413. margin-bottom: 30upx;
  414. background-color: #FFFFFF;
  415. border-radius: 12px;
  416. .rubbishType-type{
  417. margin-bottom: 36upx;
  418. font-size: 28upx;
  419. font-weight: 400;
  420. color: #000000;
  421. }
  422. .rubbish{
  423. font-size:24upx;
  424. overflow-x: scroll;
  425. .rubbishType-item{
  426. display: flex;
  427. flex-direction: column;
  428. align-items: center;
  429. min-width: 24.5%;
  430. }
  431. }
  432. }
  433. .statistics-box:last-child{
  434. margin-bottom:0 ;
  435. }
  436. }
  437. }
  438. </style>