提交 0f0712f6 编写于 作者: D devil

del tt

上级 d5dd5bea
......@@ -68,7 +68,7 @@ App({
// 请求地址
request_url: "{{request_url}}",
request_url: 'http://shopxo.com/',
// request_url: 'https://dev.shopxo.net/',
request_url: 'https://dev.shopxo.net/',
// 基础信息
application_title: "{{application_title}}",
......
{
"pages": ["pages/plugins/distribution/user/user",
"pages": [
"pages/index/index",
"pages/goods-category/goods-category",
"pages/cart/cart",
......@@ -41,7 +41,7 @@
"pages/plugins/membershiplevelvip/poster/poster",
"pages/plugins/membershiplevelvip/team/team",
"pages/plugins/distribution/user/user",
"pages/plugins/distribution/order/order",
"pages/plugins/distribution/order-detail/order-detail",
"pages/plugins/distribution/profit/profit",
......
App({
data: {
// 用户登录缓存key
cache_user_login_key: "cache_user_login_key",
// 用户信息缓存key
cache_user_info_key: "cache_shop_user_info_key",
// 用户站点信息缓存key
cache_user_merchant_key: "cache_shop_user_merchant_key",
// 设备信息缓存key
cache_system_info_key: "cache_shop_system_info_key",
// 用户地址选择缓存key
cache_buy_user_address_select_key: "cache_buy_user_address_select_key",
// 启动参数缓存key
cache_launch_info_key: "cache_shop_launch_info_key",
// 默认用户头像
default_user_head_src: "/images/default-user.png",
// 成功圆形提示图片
default_round_success_icon: "/images/default-round-success-icon.png",
// 错误圆形提示图片
default_round_error_icon: "/images/default-round-error-icon.png",
// tabbar页面
tabbar_pages: ["/pages/index/index", "/pages/goods-category/goods-category", "/pages/cart/cart", "/pages/user/user"],
// 页面标题
common_pages_title: {
"goods_search": "商品搜索",
"goods_detail": "商品详情",
"goods_attribute": "属性",
"user_address": "我的地址",
"user_address_save_add": "新增地址",
"user_address_save_edit": "编辑地址",
"buy": "订单确认",
"user_order": "我的订单",
"user_order_detail": "订单详情",
"user_favor": "我的收藏",
"answer_form": "留言",
"answer_list": "问答",
"user_answer_list": "我的留言",
"user": "用户中心",
"goods_category": "分类",
"cart": "购物车",
"message": "消息",
"user_integral": "我的积分",
"user_goods_browse": "我的足迹",
"goods_comment": "商品评论",
"user_orderaftersale": "退款/售后",
"user_orderaftersale_detail": "订单售后",
"user_order_comments": "订单评论",
"coupon": "领劵中心",
"user_coupon": "优惠劵",
"extraction_address": "自提地址"
},
// 请求地址
request_url: "{{request_url}}",
request_url: 'http://shopxo.com/',
request_url: 'https://dev.shopxo.net/',
// 基础信息
application_title: "{{application_title}}",
application_describe: "{{application_describe}}"
},
/**
* 小程序初始化
*/
onLaunch(options) {
// 启动参数处理
options = this.launch_params_handle(options); // 设置设备信息
this.set_system_info(); // 缓存启动参数
tt.setStorage({
key: this.data.cache_launch_info_key,
data: options
});
},
/**
* 启动参数处理
*/
launch_params_handle(params) {
// 启动参数处理
if ((params.query || null) != null) {
params = params.query;
}
if ((params.scene || null) != null) {
params = this.url_params_to_json(decodeURIComponent(params.scene));
}
return params;
},
/**
* 获取设备信息
*/
get_system_info() {
let system_info = tt.getStorageSync(this.data.cache_system_info_key) || null;
if (system_info == null) {
return this.set_system_info();
}
return system_info;
},
/**
* 设置设备信息
*/
set_system_info() {
var system_info = tt.getSystemInfoSync();
tt.setStorage({
key: this.data.cache_system_info_key,
data: system_info
});
return system_info;
},
/**
* 请求地址生成
* a 方法
* c 控制器
* plugins 插件标记(传参则表示为插件请求)
* params url请求参数
*/
get_request_url(a, c, plugins, params) {
a = a || "index";
c = c || "index"; // 是否插件请求
var plugins_params = "";
if ((plugins || null) != null) {
plugins_params = "&pluginsname=" + plugins + "&pluginscontrol=" + c + "&pluginsaction=" + a; // 走api统一插件调用控制器
c = "plugins";
a = "index";
} // 参数处理
params = params || "";
if (params != "" && params.substr(0, 1) != "&") {
params = "&" + params;
} // 用户信息
var user = this.get_user_cache_info();
var token = user == false ? '' : user.token || '';
return this.data.request_url + "index.php?s=/api/" + c + "/" + a + plugins_params + "&application=app&application_client_type=weixin" + "&token=" + token + "&ajax=ajax" + params;
},
/**
* 获取用户信息,信息不存在则唤醒授权
* object 回调操作对象
* method 回调操作对象的函数
* return 有用户数据直接返回, 则回调调用者
*/
get_user_info(object, method) {
var user = this.get_user_cache_info();
if (user == false) {
// 唤醒用户授权
this.user_login(object, method);
return false;
} else {
return user;
}
},
/**
* 从缓存获取用户信息
*/
get_user_cache_info() {
let user = tt.getStorageSync(this.data.cache_user_info_key) || null;
if (user == null) {
return false;
}
return user;
},
/**
* 用户登录
* object 回调操作对象
* method 回调操作对象的函数
* auth_data 授权数据
*/
user_auth_login(object, method, auth_data) {
var self = this;
tt.checkSession({
success: function () {
var openid = tt.getStorageSync(self.data.cache_user_login_key) || null;
if (openid == null) {
self.user_login(object, method);
} else {
self.get_user_login_info(object, method, openid, auth_data);
}
},
fail: function () {
self.user_login(object, method);
}
});
},
/**
* 用户登录
* object 回调操作对象
* method 回调操作对象的函数
* auth_data 授权数据
*/
user_login(object, method) {
var openid = tt.getStorageSync(this.data.cache_user_login_key) || null;
if (openid == null) {
var self = this; // 加载loding
tt.showLoading({
title: "授权中..."
});
tt.login({
success: res => {
if (res.code) {
tt.request({
url: self.get_request_url('wechatuserauth', 'user'),
method: 'POST',
data: {
authcode: res.code
},
dataType: 'json',
header: {
'content-type': 'application/x-www-form-urlencoded'
},
success: res => {
tt.hideLoading();
if (res.data.code == 0) {
var data = res.data.data;
if ((data.is_alipay_user_exist || 0) == 1) {
tt.setStorage({
key: self.data.cache_user_info_key,
data: data,
success: res => {
if (typeof object === 'object' && (method || null) != null) {
object[method]();
}
},
fail: () => {
self.showToast('用户信息缓存失败');
}
});
} else {
tt.setStorage({
key: self.data.cache_user_login_key,
data: data.openid
});
self.login_to_auth();
}
} else {
tt.hideLoading();
self.showToast(res.data.msg);
}
},
fail: () => {
tt.hideLoading();
self.showToast('服务器请求出错');
}
});
}
},
fail: e => {
tt.hideLoading();
self.showToast('授权失败');
}
});
} else {
this.login_to_auth();
}
},
/**
* 跳转到登录页面授权
*/
login_to_auth() {
tt.showModal({
title: '温馨提示',
content: '授权用户信息',
confirmText: '确认',
cancelText: '暂不',
success: result => {
if (result.confirm) {
tt.navigateTo({
url: "/pages/login/login"
});
}
}
});
},
/**
* 获取用户授权信息
* object 回调操作对象
* method 回调操作对象的函数
* openid 用户openid
* auth_data 授权数据
*/
get_user_login_info(object, method, openid, auth_data) {
// 邀请人参数
var params = tt.getStorageSync(this.data.cache_launch_info_key) || null;
var referrer = params == null ? 0 : params.referrer || 0; // 远程解密数据
tt.showLoading({
title: "授权中..."
});
var self = this;
tt.request({
url: self.get_request_url('wechatuserinfo', 'user'),
method: 'POST',
data: {
"encrypted_data": auth_data.encryptedData,
"iv": auth_data.iv,
"openid": openid,
"referrer": referrer
},
dataType: 'json',
header: {
'content-type': 'application/x-www-form-urlencoded'
},
success: res => {
tt.hideLoading();
if (res.data.code == 0) {
tt.setStorage({
key: self.data.cache_user_info_key,
data: res.data.data,
success: res => {
if (typeof object === 'object' && (method || null) != null) {
object[method]();
}
},
fail: () => {
self.showToast('用户信息缓存失败');
}
});
} else {
self.showToast(res.data.msg);
}
},
fail: () => {
tt.hideLoading();
self.showToast('服务器请求出错');
}
});
},
/**
* 字段数据校验
* data 待校验的数据, 一维json对象
* validation 待校验的字段, 格式 [{fields: 'mobile', msg: '请填写手机号码', is_can_zero: 1(是否可以为0)}, ...]
*/
fields_check(data, validation) {
for (var i in validation) {
var temp_value = data[validation[i]["fields"]];
var temp_is_can_zero = validation[i]["is_can_zero"] || null;
if (temp_value == undefined || temp_value.length == 0 || temp_value == -1 || temp_is_can_zero == null && temp_value == 0) {
this.showToast(validation[i]['msg']);
return false;
}
}
return true;
},
/**
* 获取当前时间戳
*/
get_timestamp() {
return parseInt(new Date().getTime() / 1000);
},
/**
* 获取日期
* format 日期格式(默认 yyyy-MM-dd h:m:s)
* timestamp 时间戳(默认当前时间戳)
*/
get_date(format, timestamp) {
var d = new Date((timestamp || this.get_timestamp()) * 1000);
var date = {
"M+": d.getMonth() + 1,
"d+": d.getDate(),
"h+": d.getHours(),
"m+": d.getMinutes(),
"s+": d.getSeconds(),
"q+": Math.floor((d.getMonth() + 3) / 3),
"S+": d.getMilliseconds()
};
if (/(y+)/i.test(format)) {
format = format.replace(RegExp.$1, (d.getFullYear() + '').substr(4 - RegExp.$1.length));
}
for (var k in date) {
if (new RegExp("(" + k + ")").test(format)) {
format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? date[k] : ("00" + date[k]).substr(("" + date[k]).length));
}
}
return format;
},
/**
* 获取对象、数组的长度、元素个数
* obj 要计算长度的元素(object、array、string)
*/
get_length(obj) {
var obj_type = typeof obj;
if (obj_type == "string") {
return obj.length;
} else if (obj_type == "object") {
var obj_len = 0;
for (var i in obj) {
obj_len++;
}
return obj_len;
}
return false;
},
/**
* 价格保留两位小数
* price 价格保留两位小数
*/
price_two_decimal(x) {
var f_x = parseFloat(x);
if (isNaN(f_x)) {
return 0;
}
var f_x = Math.round(x * 100) / 100;
var s_x = f_x.toString();
var pos_decimal = s_x.indexOf('.');
if (pos_decimal < 0) {
pos_decimal = s_x.length;
s_x += '.';
}
while (s_x.length <= pos_decimal + 2) {
s_x += '0';
}
return s_x;
},
/**
* 当前地址是否存在tabbar中
*/
is_tabbar_pages(url) {
if (url.indexOf("?") == -1) {
var value = url;
} else {
var temp_str = url.split("?");
var value = temp_str[0];
}
if ((value || null) == null) {
return false;
}
var temp_tabbar_pages = this.data.tabbar_pages;
for (var i in temp_tabbar_pages) {
if (temp_tabbar_pages[i] == value) {
return true;
}
}
return false;
},
/**
* 事件操作
*/
operation_event(e) {
var value = e.currentTarget.dataset.value || null;
var type = parseInt(e.currentTarget.dataset.type);
if (value != null) {
switch (type) {
// web
case 0:
tt.navigateTo({
url: '/pages/web-view/web-view?url=' + encodeURIComponent(value)
});
break;
// 内部页面
case 1:
if (this.is_tabbar_pages(value)) {
tt.switchTab({
url: value
});
} else {
tt.navigateTo({
url: value
});
}
break;
// 跳转到外部小程序
case 2:
tt.navigateToMiniProgram({
appId: value
});
break;
// 跳转到地图查看位置
case 3:
var values = value.split('|');
if (values.length != 4) {
this.showToast('事件值格式有误');
return false;
}
tt.openLocation({
name: values[0],
address: values[1],
longitude: values[2],
latitude: values[3]
});
break;
// 拨打电话
case 4:
tt.makePhoneCall({
phoneNumber: value
});
break;
}
}
},
/**
* 默认弱提示方法
* msg [string] 提示信息
* status [string] 状态 默认error [正确success, 错误error]
*/
showToast(msg, status) {
if ((status || 'error') == 'success') {
tt.showToast({
title: msg,
duration: 3000
});
} else {
tt.showToast({
image: '/images/default-toast-error.png',
title: msg,
duration: 3000
});
}
},
/**
* 是否需要登录
* 是否需要绑定手机号码
*/
user_is_need_login(user) {
// 用户信息是否正确
if (user == false) {
return true;
} // 是否需要绑定手机号码
if ((user.is_mandatory_bind_mobile || 0) == 1) {
if ((user.mobile || null) == null) {
return true;
}
}
return false;
},
/**
* url参数转json对象
*/
url_params_to_json(url_params) {
var json = new Object();
if ((url_params || null) != null) {
var arr = url_params.split('&');
for (var i = 0; i < arr.length; i++) {
var temp = arr[i].split('=');
json[temp[0]] = temp[1];
}
}
return json;
},
// 拨打电话
call_tel(value) {
if ((value || null) != null) {
tt.makePhoneCall({
phoneNumber: value
});
}
},
/**
* 登录校验
* object 回调操作对象
* method 回调操作对象的函数
*/
is_login_check(res, object, method) {
if (res.code == -400) {
tt.clearStorage();
this.get_user_info(object, method);
return false;
}
return true;
},
/**
* 设置导航reddot
* index tabBar 的哪一项,从左边算起(0开始)
* type 0 移出, 1 添加 (默认 0 移出)
*/
set_tab_bar_reddot(index, type) {
if (index !== undefined && index !== null) {
if ((type || 0) == 0) {
tt.hideTabBarRedDot({
index: Number(index)
});
} else {
tt.showTabBarRedDot({
index: Number(index)
});
}
}
},
/**
* 设置导航车badge
* index tabBar 的哪一项,从左边算起(0开始)
* type 0 移出, 1 添加 (默认 0 移出)
* value 显示的文本,超过 4 个字符则显示成 ...(type参数为1的情况下有效)
*/
set_tab_bar_badge(index, type, value) {
if (index !== undefined && index !== null) {
if ((type || 0) == 0) {
tt.removeTabBarBadge({
index: Number(index)
});
} else {
tt.setTabBarBadge({
index: Number(index),
"text": value.toString()
});
}
}
}
});
\ No newline at end of file
{
"pages": [
"pages/index/index",
"pages/goods-category/goods-category",
"pages/cart/cart",
"pages/user/user",
"pages/buy/buy",
"pages/web-view/web-view",
"pages/login/login",
"pages/paytips/paytips",
"pages/goods-search/goods-search",
"pages/goods-detail/goods-detail",
"pages/goods-comment/goods-comment",
"pages/goods-attribute/goods-attribute",
"pages/user-address/user-address",
"pages/user-address-save/user-address-save",
"pages/user-order/user-order",
"pages/user-order-detail/user-order-detail",
"pages/user-order-comments/user-order-comments",
"pages/user-faovr/user-faovr",
"pages/user-answer-list/user-answer-list",
"pages/answer-list/answer-list",
"pages/answer-form/answer-form",
"pages/message/message",
"pages/user-integral/user-integral",
"pages/user-goods-browse/user-goods-browse",
"pages/user-orderaftersale/user-orderaftersale",
"pages/user-orderaftersale-detail/user-orderaftersale-detail",
"pages/extraction-address/extraction-address",
"pages/common/open-setting-location/open-setting-location",
"pages/plugins/coupon/index/index",
"pages/plugins/coupon/user/user",
"pages/plugins/membershiplevelvip/index/index",
"pages/plugins/membershiplevelvip/buy/buy",
"pages/plugins/membershiplevelvip/user/user",
"pages/plugins/membershiplevelvip/order/order",
"pages/plugins/membershiplevelvip/order-detail/order-detail",
"pages/plugins/membershiplevelvip/profit/profit",
"pages/plugins/membershiplevelvip/profit-detail/profit-detail",
"pages/plugins/membershiplevelvip/statistics/statistics",
"pages/plugins/membershiplevelvip/poster/poster",
"pages/plugins/membershiplevelvip/team/team",
"pages/plugins/distribution/user/user",
"pages/plugins/distribution/order/order",
"pages/plugins/distribution/order-detail/order-detail",
"pages/plugins/distribution/profit/profit",
"pages/plugins/distribution/profit-detail/profit-detail",
"pages/plugins/distribution/statistics/statistics",
"pages/plugins/distribution/poster/poster",
"pages/plugins/distribution/team/team",
"pages/plugins/distribution/extraction/extraction",
"pages/plugins/distribution/extraction-apply/extraction-apply",
"pages/plugins/distribution/extraction-order/extraction-order",
"pages/plugins/distribution/introduce/introduce",
"pages/plugins/wallet/user/user",
"pages/plugins/wallet/recharge/recharge",
"pages/plugins/wallet/cash-auth/cash-auth",
"pages/plugins/wallet/cash-create/cash-create",
"pages/plugins/wallet/wallet-log/wallet-log",
"pages/plugins/wallet/wallet-log-detail/wallet-log-detail",
"pages/plugins/wallet/user-recharge/user-recharge",
"pages/plugins/wallet/user-recharge-detail/user-recharge-detail",
"pages/plugins/wallet/user-cash/user-cash",
"pages/plugins/wallet/user-cash-detail/user-cash-detail"
],
"permission": {
"scope.userLocation": {
"desc": "你的位置将用于小程序中相应业务位置服务使用"
}
},
"window": {
"navigationBarTitleText": "{{application_title}}",
"navigationBarBackgroundColor": "#d2364c",
"backgroundColor": "#f5f5f5",
"backgroundColorBottom": "#f5f5f5"
},
"tabBar": {
"color": "#8a8a8a",
"selectedColor": "#d2364c",
"backgroundColor": "#fff",
"list": [
{
"pagePath": "pages/index/index",
"iconPath": "/images/nav-icon-home.png",
"selectedIconPath": "/images/nav-icon-home-active.png",
"text": "首页"
},
{
"pagePath": "pages/goods-category/goods-category",
"iconPath": "/images/nav-icon-category.png",
"selectedIconPath": "/images/nav-icon-category-active.png",
"text": "分类"
},
{
"pagePath": "pages/cart/cart",
"iconPath": "/images/nav-icon-cart.png",
"selectedIconPath": "/images/nav-icon-cart-active.png",
"text": "购物车"
},
{
"pagePath": "pages/user/user",
"iconPath": "/images/nav-icon-user.png",
"selectedIconPath": "/images/nav-icon-user-active.png",
"text": "我的"
}
]
},
"networkTimeout": {
"request": 10000,
"downloadFile": 10000
},
"plugins": {},
"debug": true,
"sitemapLocation": "sitemap.json"
}
\ No newline at end of file
/* 框架样式覆盖 */
.a-textarea-control textarea {
font-size: 12px;
}
button:after, button:before {
border: 0;
border-radius: 0;
}
/* 公共样式 */
page {
background: #f5f5f5;
color: #4a4a4a;
}
page, textarea {
font-size: 28rpx;
}
input[type="text"],
input[type="number"],
input[type="idcard"],
input[type="digit"],
textarea {
-webkit-appearance: none;
border-radius: 5px;
box-sizing: border-box;
}
/* 导航分割 */
.spacing-nav-title {
position: relative;
color: #d2364c;
text-align: center;
background-color: #ffffff;
height: 80rpx;
line-height: 80rpx;
}
.spacing-nav-title .line {
display: inline-block;
width: 50%;
height: 1px;
background: #d2364c;
position: absolute;
left: 50%;
top: 50%;
-webkit-transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%);
transform: translate(-50%,-50%);
}
.spacing-nav-title .text-wrapper {
position: relative;
display: inline-block;
padding: 0 8px;
background-color: #ffffff;
font-size: 36rpx;
font-weight: bold;
}
/* 模块分割间距 */
.spacing { padding-top: 20rpx; }
.spacing-10 { padding-top: 10rpx; }
.spacing-mb { margin-bottom: 20rpx; }
.spacing-mt { margin-top: 20rpx; }
.drift { position: fixed; left: -1000px; }
.nav-submit-fixed { background: #eee; height: 46px; position: fixed; bottom: 0; z-index: 10; }
.tips { background: #ffffeb url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAKN0lEQVR4Xu1beZAcZRX/vZ7NTn9DWJAjQKIYpKRSoqJCuHJMLwkQNjvdJEoIIMHSotRgIaIErJICpDwoCBYUFKApwYgp2Jhjejabg4Tt3oTEKkhREg4NxVUqQjgEEqZ7j+ln9exOT3dPz/bsJrs7hPSf813v/b7fe+/73vuG8Cn/6FOuPw4BcIgBY4xAT3vz6QXHuVCSSE+2Gs+PtjhjZgLcdknClvc8DNCVRaWZ90oSnZnMGP8YTRDGBADOnTfJdpxlIMwJKMv8R6GZ3zuoAchnm6eBHJ1AR4UVZWY9pZnaQQuAnW2ey3BWgkhEKcngXEo11YMOAGZIVk65npjvAJFUTcFaGWDpM08CS0tAfCKDbk+pxt+GC9qI+wBrjTKZE/w4gc6sEJJ5N4hOKf1eKwMsXdkMYNbAuD4Gfp5SjbuGA8KIAtCdS89zHFoOwvgIe19JxDcC0qseADX6AEtXXgIwxT8nA+0i2biQLtz08VCAGBEAuO3URit57FIi/KhSGGaAbhaq8SveMOMEuyfxZpkBaE+pRiZOASurfBvEywEKyM/ATlHAbJpnfBA3R6n9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OGzh12yap5WrX4QwYD0boC+OBytQ2O6GbglpRp3VJurkgGVAAxFDjunXMOM+/xjEoypjZrxTLV5KgDIZ5X7iHDNUBYevC+3ycnkd6MeL8WZwFBksHLKdDgw/EVR1w9UyxWW5q4AwL1p9bzZ1OIwl0vMNUrChIujH1bwy5LEWri8zRVhMOgEa1wWVnt6Bhxy7/w+h80vycnk1LhXYzU9kalVEGaQlVN+SozfhnbCdWF5CdLlSbUz64W5ypxgIAzWsq6dm9nCLK32H5AYeAsNmJpqMdzS2KDfAQWgtJJLR3awlghHB1d3q7S4vVTJGajflUtjoXPAYJIPlM7dx5GBx9XM+KAhQbMbWzt3xinvto8IAO7E7nM5SLzR/xK07JnxmNyEK5HHMYEXIsxVj8J+ZdzzARxpFQGByrVbzk9IlB7Kk/sRA8AVmJ+YfYSd73schIqKL8DrielaJrzsC1k1AWDpyi4AoToAv4oCzRLzDPeJT83fiAJQBKHtkoQl77mbQNdWSMV4JXBcjbkNeiamh0I1Y53chIXUbOyrWfOBjiMOQEkgO5v+IRPuDz9vDQhcIwDFAinzUoAmMuG24T6UHlEfELUTxSIFO20gaqyyU7EJkaHucFz/UWNAIEIwu/8Y6U9TBb+DHwBXX7t9+he4kFhfGSGin8jE7eL+tI86A0rCFiOE1dfuf+gsEc9PZkw36zNq35gB0B8hzhF2MvkHECYx4cFwvm40UBhTAEZDwbg1DgEQh9DB3v5/c3FujBE8RpQAAAAASUVORK5CYII=') no-repeat 5rpx 12rpx; background-size: 35rpx 35rpx; color: #f7b240; border: 1px solid #faebd2; line-height: 38rpx; padding: 10rpx 10rpx 10rpx 45rpx; font-size: 26rpx; border-radius: 2px; display: block; }
.data-loding image { width: 60px; height: 60px; background-size: 80% 80% !important; }
/* 边框 */
.br { border: solid 1px #efefef; }
.br-b { border-bottom: solid 1px #efefef; }
.br-t { border-top: solid 1px #efefef; }
.br-l { border-left: solid 1px #efefef; }
.br-r { border-right: solid 1px #efefef; }
/* 虚线边框 */
.br-dashed { border: dashed 1px #efefef; }
.br-b-dashed { border-bottom: dashed 1px #efefef; }
.br-t-dashed { border-top: dashed 1px #efefef; }
.br-l-dashed { border-left: dashed 1px #efefef; }
.br-r-dashed { border-right: dashed 1px #efefef; }
/* 箭头符号 */
.arrow-right { background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAA+klEQVRYR+3WsWrDMBAG4P/eotCQLlk73UGfq6O3BgLNEsg7JQQPZ7ADfos8gAeBijYTAsnpREJBXmX0f/7RCRNe/NCL81EBtYH/1YCq/gK4iMiu1PSYGlDVloi+AOyZ+bsEwgQYx/FtmqYDgFUphAmQvniOiDFuRaTxNGEGlEZkAWaIFsCHp4lsQEIMw7AIIRw9CBfgGgFgzcw/ljPhBtxoohGR7aOIIoC+799DCCciWsYYnwvwhKeWXA14w12AEuHZgFLhWYCS4WbAPDxn5m+NpukQquqZiD49V+81wgToum6TfkiYef/oRXPvPRPg3mY56xVQG6gN/AEiuagh/yEjYQAAAABJRU5ErkJggg=='); background-size: 18px 18px; background-repeat: no-repeat; background-position: center right; }
/* 常用样式 */
.fl { float: left; }
.fr { float: right; }
.bg-white { background-color: #fff; }
.wh-auto { width: 100%; }
.ht-auto { height: 100%; }
.tc { text-align: center; }
.tl { text-align: left; }
.tr { text-align: right; }
.oh { overflow: hidden; }
.dis-none { display: none; }
.dis-block { display: block; }
.cr-main { color: #d2364c; }
.cr-666 { color: #666; }
.cr-888 { color: #888; }
.cr-ccc { color: #ccc; }
.cr-fff { color: #fff; }
.my-btn-default{
font-size: 38rpx;
color: #fff !important;
border: none !important;
background-color:#d2364c !important;
border-radius: 2px;
}
.my-btn-default.btn-disabled{
background-color: #a6a6a6 !important;
color: #fff !important;
}
.my-btn-gray{
font-size: 30rpx;
color: #fff !important;
border: none !important;
background-color:#a6a6a6 !important;
border-radius: 2px;
}
/* 文字超出部分使用省略号 */
.single-text {
-o-text-overflow: ellipsis;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
max-width: 100%;
}
.multi-text {
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
/* 没有数据状态/处理错误/加载中 */
.no-data-box {
padding: 80rpx 0;
}
.no-data-box image {
width: 160rpx;
margin-bottom: 30rpx;
}
.no-data-box .no-data-tips {
font-size: 28rpx;
color: #a6a6a6;
}
.no-data-loding {
padding-top: 15%;
padding-bottom: 10px;
}
/* 底线 */
.data-bottom-line{
padding: 40rpx;
overflow: hidden;
}
.data-bottom-line view {
width: 33.3%;
}
.data-bottom-line .left, .data-bottom-line .right{
margin-top: 5px;
border-bottom: 1px solid #e1e1e1;
}
.data-bottom-line .msg{
color: #999;
text-align: center;
font-size: 24rpx;
}
/* 业务公共 */
.copyright {
color: #a5a5a5;
text-align: center;
padding: 20rpx 0;
}
.copyright .text {
font-size: 26rpx;
font-weight: 400;
}
.sales-price {
color: #f40;
font-weight: bold;
font-size: 32rpx;
}
.original-price {
color: #888;
font-size: 26rpx;
text-decoration: line-through;
margin-left: 10rpx;
}
.submit-fixed {
position: fixed;
left: 0;
bottom: 0;
background: #d2364c !important;
color: #fff !important;
border: none;
width: 100%;
}
.bg-main, .bg-primary, .bg-warning {
color: #fff !important;
border: 0;
font-size: 34rpx;
}
.bg-main {
background-color: #d2364c !important;
}
.bg-primary {
background-color: #ed6977 !important;
}
.bg-warning {
background-color: #F37B1D !important;
}
.bg-active-main {
background-color: #d2364c !important;
color: #fff !important;
}
.submit-bottom {
height: 85rpx;
line-height: 85rpx;
font-size: 32rpx;
border-radius: 0;
}
button[disabled].bg-main {
background-color: #fbe0e5 !important;
color: #f7b6c2 !important;
}
button[disabled].bg-warning {
background-color: #ffcda6 !important;
color: #fdae70 !important;
}
button[disabled].bg-primary {
background-color: #ffd2d7 !important;
color: #ffa0ab !important;
}
.nav-back {
position: fixed;
left: 0;
bottom: 10%;
}
/*
滚动标签高度
*/
.scroll-box {
height: 100vh;
}
/*
分享组建样式
*/
.share-popup {
padding: 20rpx 10rpx 0 10rpx;
position: relative;
}
.share-popup .close {
position: absolute;
top: 20rpx;
right: 20rpx;
z-index: 2;
}
.share-popup-content {
padding: 0 20rpx;
margin-top: 40rpx;
text-align: left;
}
.share-popup-content .share-items {
padding: 30rpx 0;
height: 85rpx;
}
.share-popup-content .share-items:not(:first-child) {
border-top: 1px solid #f0f0f0;
}
.share-popup-content .share-items button {
background: transparent;
padding: 0;
width: 100%;
text-align: left;
margin: 0;
}
.share-popup-content .share-items image {
width: 80rpx;
height: 80rpx;
vertical-align: middle;
margin-right: 20rpx;
}
.share-popup-content .share-items .single-text {
width: calc(100% - 100rpx);
line-height: 85rpx;
}
/**
* 快捷导航
*/
.common-quick-nav {
border: 0;
padding: 15rpx;
background: rgba(0, 0, 0, 0.6);
position: fixed;
right: 10rpx;
border-radius: 50%;
width: 90rpx;
height: 90rpx;
z-index: 1;
}
.common-quick-nav image {
width: 60rpx;
height: 60rpx;
}
/**
* 在线客服
*/
.common-online-service {
bottom: 35%;
}
/**
* 表单
*/
.form-container .form-gorup {
padding: 20rpx 10rpx;
margin-bottom: 20rpx;
}
.form-container .form-gorup-title {
margin-bottom: 5rpx;
font-weight: 500;
}
.form-container .form-group-tips,
.form-container .form-group-tips-must {
margin-left: 20rpx;
font-size: 24rpx;
color: #ccc;
}
.form-container .form-group-tips-must {
color: #f00;
}
.form-container .form-gorup input,
.form-container .form-gorup textarea,
.form-container .form-gorup .picker {
border-radius: 0;
width: 100%;
box-sizing: border-box;
padding: 0 10rpx;
font-size: 28rpx;
}
.form-container .form-gorup input,
.form-container .form-gorup .picker {
height: 70rpx;
line-height: 70rpx;
}
.form-container .form-gorup textarea {
padding: 0;
min-height: 70rpx;
}
.form-container .form-gorup-text {
padding: 20rpx 10rpx;
}
/**
* 表单图片上传
*/
.form-container-upload .form-upload-data .item {
padding: 10rpx;
position: relative;
}
.form-container-upload .form-upload-data .delete-icon {
position: absolute;
top: 15rpx;
right: 15rpx;
color: #e5e5e5;
background-color: #d9534f;
padding: 5rpx 18rpx;
font-size: 30rpx;
border-style: solid;
border-width: 0 0 1px 1px;
border-color: #eee;
}
.form-container-upload .form-upload-data image {
width: 200rpx;
height: 200rpx;
padding: 5rpx;
border: 1px solid #eee;
display: block;
}
.form-container-upload .upload-icon {
margin: 10rpx 0 0 10rpx;
width: 210rpx;
height: 210rpx;
border: 1px dashed #e9e9e9;
}
/*
* 优惠劵 - 插件
*/
.coupon-container {
padding: 0 10rpx;
}
.coupon-container .item {
overflow: hidden;
height: 180rpx;
border: 1px solid #D2364C;
}
.coupon-container .v-left {
width: calc(100% - 140rpx);
padding: 30rpx 0 30rpx 20rpx;
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
}
.coupon-container .v-left .base {
color: #D2364C;
}
.coupon-container .v-left .base .symbol {
font-family: Verdana, Tahoma;
font-size: 48rpx;
font-weight: 400;
}
.coupon-container .v-left .base .price {
font-weight: 700;
font-family: arial;
font-size: 76rpx;
}
.coupon-container .v-left .base .desc {
margin-left: 20rpx;
}
.coupon-container .v-left base-tips, .coupon-container .v-left .base-time {
margin-top: 10rpx;
}
.coupon-container .v-right {
background: #d2364c;
width: 140rpx;
height: 180rpx;
color: #fff;
font-weight: 500;
position: relative;
text-align: center;
}
.coupon-container .v-right:before {
content: '';
display: inline-block;
height: 100%;
vertical-align: middle;
}
.coupon-container .v-right .circle {
display: block;
position: absolute;
left: -1px;
top: -3px;
width: 3px;
height: 180rpx;
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAACpCAYAAADur4c3AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA3NpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0Y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Yvz//z8DDDAxIAFyOVeBOAHEYfyPMDsLmXMfmfMT2YADDP8h4CEQq4A4aUDMA1LNSKZDXwJxGcg1yJaWIXOeInO+IxuwA+acK0AsA+IEADEbic7hhPOAer4DcQcQMyNb2oLMeYVsADcyZwPMObuBWBTEsQFpI9E54sjO+QvEc0F+YoHKJgHxJ2TnvEM2gBmZswrmnA1AzAXiaJPhHC1k58BNQ3bBTGTOR2QD/iJzFsH8Mw/kHxBHggzn2KA7BxzWyC5Yisz5imwACmc2LLY7QbEN4nCS4ZwAIGZFds5lUEpEdsF6nKn3PTJnAsiAV0BcBsSM5GamFCDmQXYOOJ8iu2Anzrz9HKU8ABlwDYgTKcnbo0XNaFEzWtQgipqOYVLUAAQYAKPWa4c8cIHnAAAAAElFTkSuQmCC) no-repeat;
}
.coupon-container .item-disabled .v-right {
background: #dfdfdf !important;
color: #c0c0c0 !important;
cursor: no-drop !important;
}
.coupon-container .item-disabled {
border: 1px solid #dfdfdf !important;
}
\ No newline at end of file
// components/badge.js
Component({
/**
* 组件的属性列表
*/
properties: {
propNumber: Number
},
/**
* 组件的初始数据
*/
data: {},
/**
* 组件的方法列表
*/
methods: {}
});
\ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<view tt:if="{{propNumber > 0}}" class="am-badge">
<view class="am-badge-text {{(propNumber > 99) ? 'am-badge-text-max' : ''}}">
<text>{{(propNumber > 99) ? '99+' : propNumber}}</text>
</view>
</view>
\ No newline at end of file
.am-badge {
display: inline-block;
position: relative;
vertical-align: middle;
}
.am-badge-text {
display: inline-block;
position: absolute;
right: 0;
transform: translate(50%, -50%);
top: 0px;
min-width: 16px;
padding: 0;
height: 16px;
line-height: 16px;
text-align: center;
background-color: #FF3B30;
border-radius: 16px;
color: #fff;
font-size: 10px;
padding: 1px 1px;
}
.am-badge-text-max {
padding: 1px 2px;
}
\ No newline at end of file
import WxCanvas from './wx-canvas';
import * as echarts from './echarts';
let ctx;
Component({
properties: {
canvasId: {
type: String,
value: 'ec-canvas'
},
ec: {
type: Object
}
},
data: {},
ready: function () {
if (!this.data.ec) {
console.warn('组件需绑定 ec 变量,例:<ec-canvas id="mychart-dom-bar" ' + 'canvas-id="mychart-bar" ec="{{ ec }}"></ec-canvas>');
return;
}
if (!this.data.ec.lazyLoad) {
this.init();
}
},
methods: {
init: function (callback) {
const version = tt.version.version.split('.').map(n => parseInt(n, 10));
const isValid = version[0] > 1 || version[0] === 1 && version[1] > 9 || version[0] === 1 && version[1] === 9 && version[2] >= 91;
if (!isValid) {
console.error('微信基础库版本过低,需大于等于 1.9.91。' + '参见:https://github.com/ecomfe/echarts-for-weixin' + '#%E5%BE%AE%E4%BF%A1%E7%89%88%E6%9C%AC%E8%A6%81%E6%B1%82');
return;
}
ctx = tt.createCanvasContext(this.data.canvasId, this);
const canvas = new WxCanvas(ctx, this.data.canvasId);
echarts.setCanvasCreator(() => {
return canvas;
});
var query = tt.createSelectorQuery().in(this);
query.select('.ec-canvas').boundingClientRect(res => {
if (typeof callback === 'function') {
this.chart = callback(canvas, res.width, res.height);
} else if (this.data.ec && typeof this.data.ec.onInit === 'function') {
this.chart = this.data.ec.onInit(canvas, res.width, res.height);
} else {
this.triggerEvent('init', {
canvas: canvas,
width: res.width,
height: res.height
});
}
}).exec();
},
canvasToTempFilePath(opt) {
if (!opt.canvasId) {
opt.canvasId = this.data.canvasId;
}
ctx.draw(true, () => {
tt.canvasToTempFilePath(opt, this);
});
},
touchStart(e) {
if (this.chart && e.touches.length > 0) {
var touch = e.touches[0];
var handler = this.chart.getZr().handler;
handler.dispatch('mousedown', {
zrX: touch.x,
zrY: touch.y
});
handler.dispatch('mousemove', {
zrX: touch.x,
zrY: touch.y
});
handler.processGesture(wrapTouch(e), 'start');
}
},
touchMove(e) {
if (this.chart && e.touches.length > 0) {
var touch = e.touches[0];
var handler = this.chart.getZr().handler;
handler.dispatch('mousemove', {
zrX: touch.x,
zrY: touch.y
});
handler.processGesture(wrapTouch(e), 'change');
}
},
touchEnd(e) {
if (this.chart) {
const touch = e.changedTouches ? e.changedTouches[0] : {};
var handler = this.chart.getZr().handler;
handler.dispatch('mouseup', {
zrX: touch.x,
zrY: touch.y
});
handler.dispatch('click', {
zrX: touch.x,
zrY: touch.y
});
handler.processGesture(wrapTouch(e), 'end');
}
}
}
});
function wrapTouch(event) {
for (let i = 0; i < event.touches.length; ++i) {
const touch = event.touches[i];
touch.offsetX = touch.x;
touch.offsetY = touch.y;
}
return event;
}
\ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<canvas class="ec-canvas" canvas-id="{{ canvasId }}" bindinit="init" bindtouchstart="{{ ec.disableTouch ? '' : 'touchStart' }}" bindtouchmove="{{ ec.disableTouch ? '' : 'touchMove' }}" bindtouchend="{{ ec.disableTouch ? '' : 'touchEnd' }}">
</canvas>
export default class WxCanvas {
constructor(ctx, canvasId) {
this.ctx = ctx;
this.canvasId = canvasId;
this.chart = null; // this._initCanvas(zrender, ctx);
this._initStyle(ctx);
this._initEvent();
}
getContext(contextType) {
if (contextType === '2d') {
return this.ctx;
}
} // canvasToTempFilePath(opt) {
// if (!opt.canvasId) {
// opt.canvasId = this.canvasId;
// }
// return wx.canvasToTempFilePath(opt, this);
// }
setChart(chart) {
this.chart = chart;
}
attachEvent() {// noop
}
detachEvent() {// noop
}
_initCanvas(zrender, ctx) {
zrender.util.getContext = function () {
return ctx;
};
zrender.util.$override('measureText', function (text, font) {
ctx.font = font || '12px sans-serif';
return ctx.measureText(text);
});
}
_initStyle(ctx) {
var styles = ['fillStyle', 'strokeStyle', 'globalAlpha', 'textAlign', 'textBaseAlign', 'shadow', 'lineWidth', 'lineCap', 'lineJoin', 'lineDash', 'miterLimit', 'fontSize'];
styles.forEach(style => {
Object.defineProperty(ctx, style, {
set: value => {
if (style !== 'fillStyle' && style !== 'strokeStyle' || value !== 'none' && value !== null) {
ctx['set' + style.charAt(0).toUpperCase() + style.slice(1)](value);
}
}
});
});
ctx.createRadialGradient = () => {
return ctx.createCircularGradient(arguments);
};
}
_initEvent() {
this.event = {};
const eventNames = [{
wxName: 'touchStart',
ecName: 'mousedown'
}, {
wxName: 'touchMove',
ecName: 'mousemove'
}, {
wxName: 'touchEnd',
ecName: 'mouseup'
}, {
wxName: 'touchEnd',
ecName: 'click'
}];
eventNames.forEach(name => {
this.event[name.wxName] = e => {
const touch = e.touches[0];
this.chart.getZr().handler.dispatch(name.ecName, {
zrX: name.wxName === 'tap' ? touch.clientX : touch.x,
zrY: name.wxName === 'tap' ? touch.clientY : touch.y
});
};
});
}
}
\ No newline at end of file
const app = getApp();
Component({
data: {},
properties: {
propData: Array
},
methods: {
navigation_event(e) {
app.operation_event(e);
}
}
});
\ No newline at end of file
<view tt:if="{{propData.length > 0}}">
<view class="data-list">
<view class="items" tt:for="{{propData}}" tt:key="key">
<view class="items-content" data-value="{{item.event_value}}" data-type="{{item.event_type}}" bindtap="navigation_event" style="background-color:{{item.bg_color}}">
<image src="{{item.images_url}}" mode="aspectFit" />
</view>
<view class="title">{{item.name}}</view>
</view>
</view>
</view>
\ No newline at end of file
.data-list {
overflow: hidden;
background: #fff;
margin-bottom: 20rpx;
}
.data-list .items {
width: calc(25% - 60rpx);
float: left;
padding: 30rpx;
}
.items-content {
border-radius: 50%;
padding: 20rpx;
text-align: center;
width: 90rpx;
height: 90rpx;
}
.data-list .items image {
width: 80rpx !important;
height: 80rpx !important;
margin-top: 5rpx;
}
.data-list .items .title {
margin-top: 10rpx;
font-size: 32rpx;
text-align:center;
-o-text-overflow: ellipsis;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
max-width: 100%;
}
\ No newline at end of file
// components/popup.js
Component({
/**
* 组件的属性列表
*/
properties: {
propClassname: String,
propShow: Boolean,
propPosition: String,
propMask: Boolean,
propAnimation: Boolean,
propDisablescroll: Boolean
},
/**
* 组件的初始数据
*/
data: {},
/**
* 组件的方法列表
*/
methods: {
onMaskTap: function onMaskTap() {
this.triggerEvent('onclose', {}, {});
}
}
});
\ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<view class="am-popup {{propClassname || ''}} {{(propShow || false) ? 'am-popup-show' : ''}} {{ (propAnimation || true) ? 'animation': '' }}" disable-scroll="{{propDisablescroll || true}}">
<view class="am-popup-mask" tt:if="{{propMask || true}}" bindtap="onMaskTap"></view>
<view class="am-popup-content am-popup-{{propPosition || 'bottom'}}">
<slot></slot>
</view>
</view>
\ No newline at end of file
.am-popup-content {
position: fixed;
background:#fff;
z-index: 101;
}
.am-popup-mask {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color: rgba(0, 0, 0, 0.75);
opacity: 0;
pointer-events: none;
z-index: 100;
}
.am-popup-left {
transform: translateX(-100%);
left: 0;
top: 0;
bottom: 0;
}
.am-popup-right {
transform: translateX(100%);
right: 0;
top: 0;
bottom: 0;
}
.am-popup-top {
top: 0;
width: 100vw;
transform: translateY(-100%);
}
.am-popup-bottom {
bottom: 0;
width: 100vw;
transform: translateY(100%);
}
.am-popup-show .am-popup-content {
transform: none;
}
.am-popup-show .am-popup-mask {
opacity: 1;
pointer-events: auto;
}
.am-popup.animation .am-popup-content {
transition: all 0.15s linear;
}
.am-popup.animation .am-popup-mask {
transition: all 0.15s linear;
}
\ No newline at end of file
const app = getApp();
Component({
data: {
indicator_dots: false,
indicator_color: 'rgba(0, 0, 0, .3)',
indicator_active_color: '#e31c55',
autoplay: true,
circular: true
},
properties: {
propData: Array
},
methods: {
banner_event(e) {
app.operation_event(e);
}
}
});
\ No newline at end of file
{
"component": true
}
\ No newline at end of file
<swiper indicator-dots="{{propData.length > 0}}" indicator-color="{{indicator_color}}" indicator-active-color="{{indicator_active_color}}" autoplay="{{propData.length > 0}}" circular="{{circular}}" class="banner" tt:if="{{propData.length > 0}}">
<block tt:for="{{propData}}" tt:key="key">
<swiper-item>
<image src="{{item.images_url}}" mode="widthFix" data-value="{{item.event_value}}" data-type="{{item.event_type}}" bindtap="banner_event" />
</swiper-item>
</block>
</swiper>
\ No newline at end of file
.banner {
background: #fff;
margin-bottom: 20rpx;
}
.banner image {
min-width: 100%;
}
.banner, .banner image {
height: 320rpx !important;
}
\ No newline at end of file
此差异已折叠。
const app = getApp();
Page({
data: {
form_submit_loading: false
},
onLoad() {},
onShow() {
tt.setNavigationBarTitle({
title: app.data.common_pages_title.answer_form
});
this.init();
},
// 初始化
init() {
var user = app.get_user_info(this, "init");
if (user != false) {
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.redirectTo({
url: "/pages/login/login?event_callback=init"
});
return false;
}
}
},
/**
* 表单提交
*/
formSubmit(e) {
// 数据验证
var validation = [{
fields: 'name',
msg: '请填写联系人'
}, {
fields: 'tel',
msg: '请填写联系电话'
}, {
fields: 'content',
msg: '请填写内容'
}];
if (app.fields_check(e.detail.value, validation)) {
tt.showLoading({
title: '提交中...'
});
this.setData({
form_submit_loading: true
}); // 网络请求
tt.request({
url: app.get_request_url('add', 'answer'),
method: 'POST',
data: e.detail.value,
dataType: 'json',
header: {
'content-type': 'application/x-www-form-urlencoded'
},
success: res => {
tt.hideLoading();
if (res.data.code == 0) {
app.showToast(res.data.msg, "success");
setTimeout(function () {
tt.redirectTo({
url: "/pages/user-answer-list/user-answer-list"
});
}, 2000);
} else {
this.setData({
form_submit_loading: false
});
if (app.is_login_check(res.data)) {
app.showToast(res.data.msg);
} else {
app.showToast('提交失败,请重试!');
}
}
},
fail: () => {
tt.hideLoading();
this.setData({
form_submit_loading: false
});
app.showToast('服务器请求出错');
}
});
}
}
});
\ No newline at end of file
{
"enablePullDownRefresh": false
}
\ No newline at end of file
<form bindsubmit="formSubmit">
<view class="form-input bg-white spacing-mb">
<input type="text" class="wh-auto" name="name" placeholder="联系人" maxlength="30" />
</view>
<view class="form-input bg-white spacing-mb">
<input type="number" class="wh-auto" name="tel" placeholder="联系电话" maxlength="15" />
</view>
<view class="form-input bg-white spacing-mb">
<textarea name="content" class="content-textarea" maxlength="160" placeholder="请详细描述问题,我们将尽快为您解答!" />
</view>
<view class="bottom-btn-box fixed">
<button type="default" formType="submit" class="my-btn-default" hover-class="none" bindtap="submit_event" loading="{{form_submit_loading}}" disabled="{{form_submit_loading}}">提交</button>
</view>
</form>
\ No newline at end of file
.content{
padding: 10rpx;
}
.content-textarea {
padding-top: 10rpx;
min-height: 20vh;
}
.bottom-btn-box {
margin-top: 160rpx;
padding: 0 10rpx;
}
.form-input {
padding: 20rpx 10rpx;
}
.form-input input, .form-input textarea {
font-size: 30rpx;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
}
\ No newline at end of file
const app = getApp();
Page({
data: {
data_list: [],
data_page_total: 0,
data_page: 1,
data_list_loding_status: 1,
data_bottom_line_status: false
},
onLoad() {
this.get_data_list();
},
onShow() {
tt.setNavigationBarTitle({
title: app.data.common_pages_title.answer_list
});
},
get_data_list(is_mandatory) {
// 分页是否还有数据
if ((is_mandatory || 0) == 0) {
if (this.data.data_bottom_line_status == true) {
return false;
}
} // 加载loding
this.setData({
data_list_loding_status: 1
}); // 获取数据
tt.request({
url: app.get_request_url("common", "answer"),
method: "POST",
data: {
page: this.data.data_page
},
dataType: "json",
header: {
'content-type': 'application/x-www-form-urlencoded'
},
success: res => {
tt.stopPullDownRefresh();
if (res.data.code == 0) {
if (res.data.data.data.length > 0) {
if (this.data.data_page <= 1) {
var temp_data_list = res.data.data.data;
} else {
var temp_data_list = this.data.data_list;
var temp_data = res.data.data.data;
for (var i in temp_data) {
temp_data_list.push(temp_data[i]);
}
}
this.setData({
data_list: temp_data_list,
data_total: res.data.data.total,
data_page_total: res.data.data.page_total,
data_list_loding_status: 3,
data_page: this.data.data_page + 1
}); // 是否还有数据
if (this.data.data_page > 1 && this.data.data_page > this.data.data_page_total) {
this.setData({
data_bottom_line_status: true
});
} else {
this.setData({
data_bottom_line_status: false
});
}
} else {
this.setData({
data_list_loding_status: 0
});
}
} else {
this.setData({
data_list_loding_status: 0
});
if (app.is_login_check(res.data, this, 'get_data_list')) {
app.showToast(res.data.msg);
}
}
},
fail: () => {
tt.stopPullDownRefresh();
this.setData({
data_list_loding_status: 2
});
app.showToast("服务器请求出错");
}
});
},
// 下拉刷新
onPullDownRefresh() {
this.setData({
data_page: 1
});
this.get_data_list(1);
},
// 滚动加载
scroll_lower(e) {
this.get_data_list();
},
// 头像加载错误
user_avatar_error(e) {
var index = e.currentTarget.dataset.index || 0;
var temp_data_list = this.data_list;
for (var i in temp_data_list) {
if (i == index) {
temp_data_list[i]['avatar'] = app.data.default_user_head_src;
}
}
this.setData({
data_list: temp_data_list
});
}
});
\ No newline at end of file
{
"enablePullDownRefresh": true
}
\ No newline at end of file
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册