Browse Source

首页banner挑战

master
kola-web 3 months ago
parent
commit
89331c91db
  1. 3
      src/app.json
  2. 11
      src/pages/home/index.scss
  3. 43
      src/pages/home/index.ts
  4. 36
      src/pages/home/index.wxml
  5. 5
      src/pages/longPicture/index.json
  6. 3
      src/pages/longPicture/index.scss
  7. 17
      src/pages/longPicture/index.ts
  8. 1
      src/pages/longPicture/index.wxml

3
src/app.json

@ -11,7 +11,8 @@
"pages/article/index", "pages/article/index",
"pages/search/index", "pages/search/index",
"pages/protocol/index", "pages/protocol/index",
"pages/userInfo/index" "pages/userInfo/index",
"pages/longPicture/index"
], ],
"preloadRule": {}, "preloadRule": {},
"window": { "window": {

11
src/pages/home/index.scss

@ -48,6 +48,12 @@ page {
.wx-swiper-dots { .wx-swiper-dots {
bottom: 60rpx; bottom: 60rpx;
display: flex;
align-items: center;
}
.wx-swiper-dot{
width: 8rpx;
height: 8rpx;
} }
.wx-swiper-dot-active { .wx-swiper-dot-active {
width: 24rpx !important; width: 24rpx !important;
@ -65,9 +71,10 @@ page {
display: block; display: block;
width: 100%; width: 100%;
height: 274rpx; height: 274rpx;
border-radius: 32rpx;
} }
&::after { &::after {
content: ""; content: '';
position: absolute; position: absolute;
bottom: 74rpx; bottom: 74rpx;
left: 40rpx; left: 40rpx;
@ -123,7 +130,7 @@ page {
color: #222222; color: #222222;
font-weight: bold; font-weight: bold;
&::before { &::before {
content: ""; content: '';
width: 8rpx; width: 8rpx;
height: 34rpx; height: 34rpx;
background-color: #3795f7; background-color: #3795f7;

43
src/pages/home/index.ts

@ -5,15 +5,43 @@ Page({
cateList: [] as any, cateList: [] as any,
remark: '', remark: '',
isLogin: 0, feedbackCount: 0,
bannerList: [],
}, },
onLoad() { onLoad() {
app.waitLogin().then(() => { app.waitLogin().then(() => {
this.getCateList(); this.getCateList();
this.getBanner();
this.getRemarkCount();
});
},
getBanner() {
wx.ajax({
method: 'GET',
url: '?r=shizhong/index/index',
data: {},
}).then((res) => {
this.setData({ this.setData({
isLogin: app.globalData.isLogin, bannerList: res,
});
});
},
handleTap(e) {
const { index } = e.currentTarget.dataset;
const bannerItem: any = this.data.bannerList[index];
if (bannerItem.configType === '1') {
wx.navigateTo({
url: `/pages/article/index?id=${bannerItem.configContent}`,
}); });
} else if (bannerItem.configType === '2') {
wx.navigateTo({
url: `/pages/article/index?id=${bannerItem.configContent}`,
});
} else if (bannerItem.configType === '3') {
wx.navigateTo({
url: `/pages/longPicture/index?url=${encodeURIComponent(bannerItem.configContent)}`,
}); });
}
}, },
getCateList() { getCateList() {
wx.ajax({ wx.ajax({
@ -38,6 +66,17 @@ Page({
url: '/pages/search/index', url: '/pages/search/index',
}); });
}, },
getRemarkCount() {
wx.ajax({
method: 'GET',
url: '?r=shizhong/account/get-can-feedback-count',
data: {},
}).then((res) => {
this.setData({
feedbackCount: res,
});
});
},
handleRemark() { handleRemark() {
const { remark } = this.data; const { remark } = this.data;
wx.ajax({ wx.ajax({

36
src/pages/home/index.wxml

@ -1,7 +1,4 @@
<view <view class="page" style="background: url('{{imageUrl}}home-bg.png?t={{Timestamp}}') no-repeat top center/100% 580rpx;padding-top:{{menuButtonInfo.top}}px;">
class="page"
style="background: url('{{imageUrl}}home-bg.png?t={{Timestamp}}') no-repeat top center/100% 580rpx;padding-top:{{menuButtonInfo.top}}px;"
>
<image class="logo" src="{{imageUrl}}home-logo.png?t={{Timestamp}}"></image> <image class="logo" src="{{imageUrl}}home-logo.png?t={{Timestamp}}"></image>
<image class="page-title" src="{{imageUrl}}home-title.png?t={{Timestamp}}"></image> <image class="page-title" src="{{imageUrl}}home-title.png?t={{Timestamp}}"></image>
<view class="page-slogan">人人都是家庭健康师,让生活更有质量</view> <view class="page-slogan">人人都是家庭健康师,让生活更有质量</view>
@ -17,9 +14,24 @@
placeholder="请输入要搜索的内容" placeholder="请输入要搜索的内容"
/> />
</view> </view>
<swiper class="swiper" indicator-dots indicator-color="rgba(255,255,255,0.62)" indicator-active-color="#FFFFFF"> <swiper
<swiper-item class="swiper-item"> class="swiper"
<image class="banner" src="{{imageUrl}}place.png?t={{Timestamp}}"></image> indicator-dots
indicator-color="rgba(255,255,255,0.62)"
indicator-active-color="#FFFFFF"
>
<swiper-item
class="swiper-item"
wx:for="{{bannerList}}"
wx:key="configId"
bind:tap="handleTap"
data-index="{{index}}"
>
<image
class="banner"
mode="aspectFill"
src="{{item.configImg}}"
></image>
</swiper-item> </swiper-item>
</swiper> </swiper>
<view class="cards"> <view class="cards">
@ -35,7 +47,7 @@
<view class="content">{{item.Intro}}</view> <view class="content">{{item.Intro}}</view>
</view> </view>
</view> </view>
<view class="remark" wx:if="{{isLogin===1}}"> <view class="remark">
<view class="r-header">留言板</view> <view class="r-header">留言板</view>
<textarea <textarea
class="r-content" class="r-content"
@ -45,6 +57,12 @@
confirm-type="send" confirm-type="send"
bindconfirm="handleRemark" bindconfirm="handleRemark"
></textarea> ></textarea>
<view class="submit" bindconfirm="handleRemark">提交</view> <view
class="submit"
wx:if="{{feedbackCount>0}}"
bindconfirm="handleRemark"
>
提交
</view>
</view> </view>
</view> </view>

5
src/pages/longPicture/index.json

@ -0,0 +1,5 @@
{
"navigationStyle": "default",
"navigationBarTitleText": "预览",
"usingComponents": {}
}

3
src/pages/longPicture/index.scss

@ -0,0 +1,3 @@
.banner {
width: 100%;
}

17
src/pages/longPicture/index.ts

@ -0,0 +1,17 @@
const _app = getApp<IAppOption>();
Page({
data: {
url: '',
},
onLoad(options) {
const { url } = options;
if (url) {
this.setData({
url: decodeURIComponent(url),
});
}
},
});
export {};

1
src/pages/longPicture/index.wxml

@ -0,0 +1 @@
<image class="banner" mode="widthFix" src="{{url}}"></image>
Loading…
Cancel
Save