Commit 286c0ae7 authored by Junling Bu's avatar Junling Bu
Browse files

chore[renard-wx]: 基于微信开发者工具的格式化代码

parent 20b97ec8
......@@ -2,139 +2,139 @@ var util = require('../../utils/util.js');
var api = require('../../config/api.js');
Page({
data: {
navList: [],
goodsList: [],
id: 0,
currentCategory: {},
scrollLeft: 0,
scrollTop: 0,
scrollHeight: 0,
page: 1,
size: 100
},
data: {
navList: [],
goodsList: [],
id: 0,
currentCategory: {},
scrollLeft: 0,
scrollTop: 0,
scrollHeight: 0,
page: 1,
size: 100
},
onLoad: function(options) {
// 页面初始化 options为页面跳转所带来的参数
var that = this;
if (options.id) {
that.setData({
id: parseInt(options.id)
});
}
onLoad: function(options) {
// 页面初始化 options为页面跳转所带来的参数
var that = this;
if (options.id) {
that.setData({
id: parseInt(options.id)
});
}
wx.getSystemInfo({
success: function(res) {
that.setData({
scrollHeight: res.windowHeight
wx.getSystemInfo({
success: function(res) {
that.setData({
scrollHeight: res.windowHeight
});
}
});
}
});
this.getCategoryInfo();
},
this.getCategoryInfo();
},
onPullDownRefresh() {
// wx.showNavigationBarLoading() //在标题栏中显示加载
this.getCategoryInfo();
// wx.hideNavigationBarLoading() //完成停止加载
wx.stopPullDownRefresh() //停止下拉刷新
},
onPullDownRefresh() {
// wx.showNavigationBarLoading() //在标题栏中显示加载
this.getCategoryInfo();
// wx.hideNavigationBarLoading() //完成停止加载
wx.stopPullDownRefresh() //停止下拉刷新
},
getCategoryInfo: function() {
let that = this;
util.request(api.GoodsCategory, {
id: this.data.id
})
.then(function(res) {
getCategoryInfo: function() {
let that = this;
util.request(api.GoodsCategory, {
id: this.data.id
})
.then(function(res) {
if (res.errno == 0) {
that.setData({
navList: res.data.brotherCategory,
currentCategory: res.data.currentCategory
});
if (res.errno == 0) {
that.setData({
navList: res.data.brotherCategory,
currentCategory: res.data.currentCategory
});
wx.setNavigationBarTitle({
title: res.data.parentCategory.name
})
wx.setNavigationBarTitle({
title: res.data.parentCategory.name
})
//nav位置
let currentIndex = 0;
let navListCount = that.data.navList.length;
for (let i = 0; i < navListCount; i++) {
currentIndex += 1;
if (that.data.navList[i].id == that.data.id) {
break;
}
}
if (currentIndex > navListCount / 2 && navListCount > 5) {
that.setData({
scrollLeft: currentIndex * 60
});
}
//nav位置
let currentIndex = 0;
let navListCount = that.data.navList.length;
for (let i = 0; i < navListCount; i++) {
currentIndex += 1;
if (that.data.navList[i].id == that.data.id) {
break;
}
}
if (currentIndex > navListCount / 2 && navListCount > 5) {
that.setData({
scrollLeft: currentIndex * 60
});
}
that.getGoodsList();
} else {
//显示错误信息
}
that.getGoodsList();
} else {
//显示错误信息
}
});
},
onReady: function() {
// 页面渲染完成
},
onShow: function() {
// 页面显示
console.log(1);
},
onHide: function() {
// 页面隐藏
},
getGoodsList: function() {
wx.showLoading({
title: '加载中',
});
});
},
onReady: function() {
// 页面渲染完成
},
onShow: function() {
// 页面显示
console.log(1);
},
onHide: function() {
// 页面隐藏
},
getGoodsList: function() {
wx.showLoading({
title: '加载中',
});
setTimeout(function() {
wx.hideLoading()
}, 2000);
setTimeout(function() {
wx.hideLoading()
}, 2000);
var that = this;
util.request(api.GoodsList, {
categoryId: that.data.currentCategory.id,
page: that.data.page,
size: that.data.size
})
.then(function(res) {
that.setData({
goodsList: res.data.goodsList,
var that = this;
util.request(api.GoodsList, {
categoryId: that.data.currentCategory.id,
page: that.data.page,
size: that.data.size
})
.then(function(res) {
that.setData({
goodsList: res.data.goodsList,
});
wx.hideLoading();
});
},
onUnload: function() {
// 页面关闭
},
switchCate: function(event) {
if (this.data.id == event.currentTarget.dataset.id) {
return false;
}
var that = this;
var clientX = event.detail.x;
var currentTarget = event.currentTarget;
if (clientX < 60) {
that.setData({
scrollLeft: currentTarget.offsetLeft - 60
});
} else if (clientX > 330) {
that.setData({
scrollLeft: currentTarget.offsetLeft
});
}
this.setData({
id: event.currentTarget.dataset.id
});
wx.hideLoading();
});
},
onUnload: function() {
// 页面关闭
},
switchCate: function(event) {
if (this.data.id == event.currentTarget.dataset.id) {
return false;
}
var that = this;
var clientX = event.detail.x;
var currentTarget = event.currentTarget;
if (clientX < 60) {
that.setData({
scrollLeft: currentTarget.offsetLeft - 60
});
} else if (clientX > 330) {
that.setData({
scrollLeft: currentTarget.offsetLeft
});
}
this.setData({
id: event.currentTarget.dataset.id
});
this.getCategoryInfo();
}
this.getCategoryInfo();
}
})
\ No newline at end of file
{
"usingComponents": {
"goodList": "/components/goodList/goodList"
}
"usingComponents": {
"goodList": "/components/goodList/goodList"
}
}
\ No newline at end of file
<view class="container">
<view class="cate-nav">
<scroll-view scroll-x="true" class="cate-nav-body" style="width: 750rpx;" scroll-left="{{scrollLeft}}">
<view wx:for="{{navList}}" class="item {{ id == item.id ? 'active' : ''}}" wx:key="id" data-id="{{item.id}}" data-index="{{index}}" bindtap="switchCate">
<view class="name">{{item.name}}</view>
</view>
</scroll-view>
</view>
<scroll-view scroll-y="true" scroll-top="{{scrollTop}}" style="height:{{scrollHeight}};">
<view class="cate-item">
<view class="h">
<text class="name">{{currentCategory.name}}</text>
<text class="desc">{{currentCategory.frontName}}</text>
</view>
<goodList goods="{{goodsList}}"></goodList>
<view class="cate-nav">
<scroll-view scroll-x="true" class="cate-nav-body" style="width: 750rpx;" scroll-left="{{scrollLeft}}">
<view wx:for="{{navList}}" class="item {{ id == item.id ? 'active' : ''}}" wx:key="id" data-id="{{item.id}}" data-index="{{index}}" bindtap="switchCate">
<view class="name">{{item.name}}</view>
</view>
</scroll-view>
</view>
</scroll-view>
<scroll-view scroll-y="true" scroll-top="{{scrollTop}}" style="height:{{scrollHeight}};">
<view class="cate-item">
<view class="h">
<text class="name">{{currentCategory.name}}</text>
<text class="desc">{{currentCategory.frontName}}</text>
</view>
<goodList goods="{{goodsList}}"></goodList>
</view>
</scroll-view>
</view>
\ No newline at end of file
.container{
background: #fff;
.container {
background: #fff;
}
.cate-nav{
position: fixed;
left:0;
top:0;
z-index: 1000;
.cate-nav {
position: fixed;
left: 0;
top: 0;
z-index: 1000;
}
.cate-nav-body{
height: 84rpx;
white-space: nowrap;
background: #fff;
border-top: 1px solid rgba(0,0,0,.15);
overflow: hidden;
.cate-nav-body {
height: 84rpx;
white-space: nowrap;
background: #fff;
border-top: 1px solid rgba(0, 0, 0, 0.15);
overflow: hidden;
}
.cate-nav .item{
display: inline-block;
height: 84rpx;
min-width: 130rpx;
padding: 0 15rpx;
.cate-nav .item {
display: inline-block;
height: 84rpx;
min-width: 130rpx;
padding: 0 15rpx;
}
.cate-nav .item .name{
display: block;
height: 84rpx;
padding: 0 20rpx;
line-height: 84rpx;
color: #333;
font-size: 30rpx;
width: auto;
.cate-nav .item .name {
display: block;
height: 84rpx;
padding: 0 20rpx;
line-height: 84rpx;
color: #333;
font-size: 30rpx;
width: auto;
}
.cate-nav .item.active .name{
color: #a78845;
border-bottom: 2px solid #a78845;
.cate-nav .item.active .name {
color: #a78845;
border-bottom: 2px solid #a78845;
}
.cate-item{
margin-top: 94rpx;
height: auto;
overflow: hidden;
.cate-item {
margin-top: 94rpx;
height: auto;
overflow: hidden;
}
.cate-item .h{
height: 145rpx;
width: 750rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.cate-item .h {
height: 145rpx;
width: 750rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.cate-item .h .name{
display: block;
height: 35rpx;
margin-bottom: 18rpx;
font-size: 30rpx;
color: #333;
.cate-item .h .name {
display: block;
height: 35rpx;
margin-bottom: 18rpx;
font-size: 30rpx;
color: #333;
}
.cate-item .h .desc{
display: block;
height: 24rpx;
font-size: 24rpx;
color: #999;
}
\ No newline at end of file
.cate-item .h .desc {
display: block;
height: 24rpx;
font-size: 24rpx;
color: #999;
}
......@@ -16,9 +16,12 @@ Page({
picPage: 1,
size: 20
},
getCommentCount: function () {
getCommentCount: function() {
let that = this;
util.request(api.CommentCount, { valueId: that.data.valueId, type: that.data.type}).then(function (res) {
util.request(api.CommentCount, {
valueId: that.data.valueId,
type: that.data.type
}).then(function(res) {
if (res.errno === 0) {
that.setData({
allCount: res.data.allCount,
......@@ -27,15 +30,15 @@ Page({
}
});
},
getCommentList: function(){
getCommentList: function() {
let that = this;
util.request(api.CommentList, {
valueId: that.data.valueId,
util.request(api.CommentList, {
valueId: that.data.valueId,
type: that.data.type,
size: that.data.size,
page: (that.data.showType == 0 ? that.data.allPage : that.data.picPage),
showType: that.data.showType
}).then(function (res) {
showType: that.data.showType
}).then(function(res) {
if (res.errno === 0) {
if (that.data.showType == 0) {
......@@ -54,7 +57,7 @@ Page({
}
});
},
onLoad: function (options) {
onLoad: function(options) {
// 页面初始化 options为页面跳转所带来的参数
this.setData({
type: options.type,
......@@ -63,23 +66,23 @@ Page({
this.getCommentCount();
this.getCommentList();
},
onReady: function () {
onReady: function() {
// 页面渲染完成
},
onShow: function () {
onShow: function() {
// 页面显示
},
onHide: function () {
onHide: function() {
// 页面隐藏
},
onUnload: function () {
onUnload: function() {
// 页面关闭
},
switchTab: function () {
switchTab: function() {
let that = this;
if (that.data.showType == 0) {
that.setData({
......@@ -98,16 +101,16 @@ Page({
}
this.getCommentList();
},
onReachBottom: function(){
onReachBottom: function() {
console.log('onPullDownRefresh');
if ( this.data.showType == 0) {
if (this.data.showType == 0) {
if (this.data.allCount / this.data.size < this.data.allPage) {
return false;
}
this.setData({
'allPage' : this.data.allPage + 1
'allPage': this.data.allPage + 1
});
} else {
if (this.data.hasPicCount / this.data.size < this.data.picPage) {
......
<view class="comments">
<view class="h">
<view class="item {{ showType == 0 ? 'active' : ''}}" bindtap="switchTab">
<view class="txt">全部({{allCount}})</view>
</view>
<view class="item {{ showType == 0 ? '' : 'active'}}" bindtap="switchTab">
<view class="txt">有图({{hasPicCount}})</view>
</view>
<view class="h">
<view class="item {{ showType == 0 ? 'active' : ''}}" bindtap="switchTab">
<view class="txt">全部({{allCount}})</view>
</view>
<view class="item {{ showType == 0 ? '' : 'active'}}" bindtap="switchTab">
<view class="txt">有图({{hasPicCount}})</view>
</view>
</view>
<view class="b">
<view class="item" wx:for="{{comments}}" wx:key="id">
<view class="info">
......
.comments{
width: 100%;
height: auto;
padding-left:30rpx;
background: #fff;
margin: 20rpx 0;
.comments {
width: 100%;
height: auto;
padding-left: 30rpx;
background: #fff;
margin: 20rpx 0;
}
.comments .h{
position: fixed;
left:0;
top:0;
z-index: 1000;
width: 100%;
display: flex;
background: #fff;
height: 84rpx;
border-bottom: 1px solid rgba(0,0,0,.15);
.comments .h {
position: fixed;
left: 0;
top: 0;
z-index: 1000;
width: 100%;
display: flex;
background: #fff;
height: 84rpx;
border-bottom: 1px solid rgba(0, 0, 0, 0.15);
}
.comments .h .item{
display: inline-block;
height: 82rpx;
width: 50%;
padding: 0 15rpx;
text-align: center;
.comments .h .item {
display: inline-block;
height: 82rpx;
width: 50%;
padding: 0 15rpx;
text-align: center;
}
.comments .h .item .txt{
display: inline-block;
height: 82rpx;
padding: 0 20rpx;
line-height: 82rpx;
color: #333;
font-size: 30rpx;
width: 170rpx;
.comments .h .item .txt {
display: inline-block;
height: 82rpx;
padding: 0 20rpx;
line-height: 82rpx;
color: #333;
font-size: 30rpx;
width: 170rpx;
}
.comments .h .item.active .txt{
color: #ab2b2b;
border-bottom: 4rpx solid #ab2b2b;
.comments .h .item.active .txt {
color: #ab2b2b;
border-bottom: 4rpx solid #ab2b2b;
}
.comments .b{
margin-top: 85rpx;
height: auto;
width: 720rpx;
.comments .b {
margin-top: 85rpx;
height: auto;
width: 720rpx;
}
.comments .b.no-h{
margin-top: 0;
.comments .b.no-h {
margin-top: 0;
}
.comments .item{
height: auto;
width: 720rpx;
overflow: hidden;
border-bottom: 1px solid #d9d9d9;
padding-bottom: 25rpx;
.comments .item {
height: auto;
width: 720rpx;
overflow: hidden;
border-bottom: 1px solid #d9d9d9;
padding-bottom: 25rpx;
}
.comments .info{
height: 127rpx;
width: 100%;
padding: 33rpx 0 27rpx 0;
.comments .info {
height: 127rpx;
width: 100%;
padding: 33rpx 0 27rpx 0;
}
.comments .user{
float: left;
width: auto;
height: 67rpx;
line-height: 67rpx;
font-size: 0;
.comments .user {
float: left;
width: auto;
height: 67rpx;
line-height: 67rpx;
font-size: 0;
}
.comments .user image{
float: left;
width: 67rpx;
height: 67rpx;
margin-right: 17rpx;
border-radius: 50%;
.comments .user image {
float: left;
width: 67rpx;
height: 67rpx;
margin-right: 17rpx;
border-radius: 50%;
}
.comments .user text{
display: inline-block;
width: auto;
height: 66rpx;
overflow: hidden;
font-size: 29rpx;
line-height: 66rpx;
.comments .user text {
display: inline-block;
width: auto;
height: 66rpx;
overflow: hidden;
font-size: 29rpx;
line-height: 66rpx;
}
.comments .time{
display: block;
float: right;
width: auto;
height: 67rpx;
line-height: 67rpx;
color: #7f7f7f;
font-size: 25rpx;
margin-right: 30rpx;
.comments .time {
display: block;
float: right;
width: auto;
height: 67rpx;
line-height: 67rpx;
color: #7f7f7f;
font-size: 25rpx;
margin-right: 30rpx;
}
.comments .comment{
width: 720rpx;
padding-right: 30rpx;
line-height: 45.8rpx;
font-size: 29rpx;
margin-bottom: 16rpx;
.comments .comment {
width: 720rpx;
padding-right: 30rpx;
line-height: 45.8rpx;
font-size: 29rpx;
margin-bottom: 16rpx;
}
.comments .imgs{
width: 720rpx;
height: 150rpx;
margin-bottom: 25rpx;
.comments .imgs {
width: 720rpx;
height: 150rpx;
margin-bottom: 25rpx;
}
.comments .imgs .img{
height: 150rpx;
width: 150rpx;
margin-right: 28rpx;
.comments .imgs .img {
height: 150rpx;
width: 150rpx;
margin-right: 28rpx;
}
.comments .spec{
width: 720rpx;
height: 25rpx;
font-size: 24rpx;
color: #999;
.comments .spec {
width: 720rpx;
height: 25rpx;
font-size: 24rpx;
color: #999;
}
.comments .spec .item{
color: #7f7f7f;
font-size: 25rpx;
.comments .spec .item {
color: #7f7f7f;
font-size: 25rpx;
}
.comments .customer-service{
width: 690rpx;
height: auto;
overflow: hidden;
margin-top: 23rpx;
background: rgba(0,0,0,.03);
padding: 21rpx;
.comments .customer-service {
width: 690rpx;
height: auto;
overflow: hidden;
margin-top: 23rpx;
background: rgba(0, 0, 0, 0.03);
padding: 21rpx;
}
.comments .customer-service .u{
font-size: 24rpx;
color: #333;
line-height: 37.5rpx;
.comments .customer-service .u {
font-size: 24rpx;
color: #333;
line-height: 37.5rpx;
}
.comments .customer-service .c{
font-size: 24rpx;
color: #999;
line-height: 37.5rpx;
}
\ No newline at end of file
.comments .customer-service .c {
font-size: 24rpx;
color: #999;
line-height: 37.5rpx;
}
......@@ -16,7 +16,7 @@ Page({
picUrls: [],
files: []
},
chooseImage: function (e) {
chooseImage: function(e) {
if (this.data.files.length >= 5) {
util.showErrorToast('只能上传五张图片')
return false;
......@@ -27,7 +27,7 @@ Page({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: function (res) {
success: function(res) {
that.setData({
files: that.data.files.concat(res.tempFilePaths)
});
......@@ -35,13 +35,13 @@ Page({
}
})
},
upload: function (res) {
upload: function(res) {
var that = this;
const uploadTask = wx.uploadFile({
url: api.StorageUpload,
filePath: res.tempFilePaths[0],
name: 'file',
success: function (res) {
success: function(res) {
var _res = JSON.parse(res.data);
if (_res.errno === 0) {
var url = _res.data.url
......@@ -52,7 +52,7 @@ Page({
})
}
},
fail: function (e) {
fail: function(e) {
wx.showModal({
title: '错误',
content: '上传失败',
......@@ -68,28 +68,24 @@ Page({
})
},
previewImage: function (e) {
previewImage: function(e) {
wx.previewImage({
current: e.currentTarget.id, // 当前显示图片的http链接
urls: this.data.files // 需要预览的图片http链接列表
})
},
selectRater: function (e) {
selectRater: function(e) {
var star = e.currentTarget.dataset.star + 1;
var starText;
if (star == 1) {
starText = '很差';
}
else if (star == 2) {
} else if (star == 2) {
starText = '不太满意';
}
else if (star == 3) {
} else if (star == 3) {
starText = '满意';
}
else if (star == 4) {
} else if (star == 4) {
starText = '比较满意';
}
else {
} else {
starText = '十分满意'
}
this.setData({
......@@ -98,7 +94,7 @@ Page({
})
},
onLoad: function (options) {
onLoad: function(options) {
var that = this;
that.setData({
orderId: options.orderId,
......@@ -107,11 +103,12 @@ Page({
});
this.getOrderGoods();
},
getOrderGoods: function () {
getOrderGoods: function() {
let that = this;
util.request(api.OrderGoods, {
orderId: that.data.orderId, goodsId: that.data.valueId
}).then(function (res) {
orderId: that.data.orderId,
goodsId: that.data.valueId
}).then(function(res) {
if (res.errno === 0) {
that.setData({
orderGoods: res.data,
......@@ -119,10 +116,10 @@ Page({
}
});
},
onClose: function () {
onClose: function() {
wx.navigateBack();
},
onPost: function () {
onPost: function() {
let that = this;
if (!this.data.content) {
......@@ -137,11 +134,11 @@ Page({
star: that.data.star,
hasPicture: that.data.hasPicture,
picUrls: that.data.picUrls
}, 'POST').then(function (res) {
}, 'POST').then(function(res) {
if (res.errno === 0) {
wx.showToast({
title: '评论成功',
complete: function () {
complete: function() {
wx.navigateBack();
}
})
......@@ -161,18 +158,18 @@ Page({
content: event.detail.value,
})
},
onReady: function () {
onReady: function() {
},
onShow: function () {
onShow: function() {
// 页面显示
},
onHide: function () {
onHide: function() {
// 页面隐藏
},
onUnload: function () {
onUnload: function() {
// 页面关闭
}
......
This diff is collapsed.
{
"navigationBarTitleText": "商品详情",
"usingComponents": {
"sharePop": "/components/sharePop/sharePop",
"goodList": "/components/goodList/goodList",
"van-notify": "../../components/notify/index"
}
"navigationBarTitleText": "商品详情",
"usingComponents": {
"sharePop": "/components/sharePop/sharePop",
"goodList": "/components/goodList/goodList",
"van-notify": "/components/notify/index"
}
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
{
"navigationBarTitleText": "团购详情",
"usingComponents": {
"navigationBarTitleText": "团购详情",
"usingComponents": {
"sharePop": "/components/sharePop/sharePop"
}
}
}
\ No newline at end of file
......@@ -2,5 +2,5 @@
"navigationBarTitleText": "团购专区",
"usingComponents": {
"zan-capsule": "/components/capsule/index"
}
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment