feat: move project
This commit is contained in:
commit
4a940f28ba
97 changed files with 5047 additions and 0 deletions
15
.gitignore
vendored
Normal file
15
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
node_modules/
|
||||
yarn-error.log
|
||||
miniprogram/
|
||||
miniprogram_npm/
|
||||
miniprogram_dist/
|
||||
.DS_Store
|
||||
$node_modules/
|
||||
.history/
|
||||
**/dist
|
||||
components/**/*.lock
|
||||
components/**/package-lock.json
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
project.private.config.json
|
||||
.eslintcache
|
||||
9
app.js
Normal file
9
app.js
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import updateManager from './common/updateManager';
|
||||
|
||||
App({
|
||||
onLaunch: function () {
|
||||
},
|
||||
onShow: function () {
|
||||
updateManager();
|
||||
},
|
||||
});
|
||||
53
app.json
Normal file
53
app.json
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
"pages": [
|
||||
"pages/home/home",
|
||||
"pages/paylist/paylist",
|
||||
"pages/news_list/home",
|
||||
"pages/news_admin_list/home",
|
||||
"pages/usercenter/index",
|
||||
"pages/detail/detail",
|
||||
"pages/detail_admin/detail",
|
||||
"pages/takephoto/takephoto",
|
||||
"pages/faxianlist/faxianlist",
|
||||
"pages/test/test",
|
||||
"pages/shop/shop",
|
||||
"pages/pay/pay",
|
||||
"pages/createpay/createpay",
|
||||
"pages/sharebuy/sharebuy",
|
||||
"pages/usercenter/info",
|
||||
"pages/sharelist/sharelist",
|
||||
"pages/webview/webview"
|
||||
],
|
||||
"tabBar": {
|
||||
"custom": true,
|
||||
"color": "#666666",
|
||||
"selectedColor": "#FF5F15",
|
||||
"backgroundColor": "#ffffff",
|
||||
"borderStyle": "black",
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "pages/home/home",
|
||||
"text": "首页"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/faxianlist/faxianlist",
|
||||
"text": "分销"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/usercenter/index",
|
||||
"text": "我的"
|
||||
}
|
||||
]
|
||||
},
|
||||
"requiredPrivateInfos": [],
|
||||
"lazyCodeLoading": "requiredComponents",
|
||||
"usingComponents": {},
|
||||
"window": {
|
||||
"backgroundTextStyle": "light",
|
||||
"navigationBarBackgroundColor": "#fff",
|
||||
"navigationBarTitleText": "Weixin",
|
||||
"navigationBarTextStyle": "black"
|
||||
},
|
||||
"sitemapLocation": "sitemap.json",
|
||||
"permission": {}
|
||||
}
|
||||
3
app.wxss
Normal file
3
app.wxss
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
@import 'style/iconfont.wxss';
|
||||
|
||||
@import 'style/theme.wxss';
|
||||
29
common/updateManager.js
Normal file
29
common/updateManager.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
export default () => {
|
||||
if (!wx.canIUse('getUpdateManager')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const updateManager = wx.getUpdateManager();
|
||||
|
||||
updateManager.onCheckForUpdate(function (res) {
|
||||
// 请求完新版本信息的回调
|
||||
console.log('版本信息', res);
|
||||
});
|
||||
|
||||
updateManager.onUpdateReady(function () {
|
||||
wx.showModal({
|
||||
title: '更新提示',
|
||||
content: '新版本已经准备好,是否重启应用?',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
||||
updateManager.applyUpdate();
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
updateManager.onUpdateFailed(function () {
|
||||
// 新版本下载失败
|
||||
});
|
||||
};
|
||||
4
config/index.js
Normal file
4
config/index.js
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
export const config = {
|
||||
/** 是否使用mock代替api返回 */
|
||||
useMock: true,
|
||||
};
|
||||
16
custom-tab-bar/data.js
Normal file
16
custom-tab-bar/data.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
export default [{
|
||||
icon: 'home',
|
||||
text: '动态',
|
||||
url: 'pages/home/home',
|
||||
},
|
||||
{
|
||||
icon: 'share',
|
||||
text: '分销',
|
||||
url: 'pages/faxianlist/faxianlist',
|
||||
},
|
||||
{
|
||||
icon: 'person',
|
||||
text: '我的',
|
||||
url: 'pages/usercenter/index',
|
||||
},
|
||||
];
|
||||
66
custom-tab-bar/index.js
Normal file
66
custom-tab-bar/index.js
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
import TabMenu from './data';
|
||||
import R from '../utils/request';
|
||||
import C from '../utils/constant';
|
||||
Component({
|
||||
data: {
|
||||
active: 0,
|
||||
list: [],
|
||||
is_share: false,
|
||||
cdnHost: C.cdnHost,
|
||||
},
|
||||
|
||||
ready() {
|
||||
R.get('/index.php/api/v1/my').then(({ model }) => {
|
||||
this.setData({
|
||||
is_share: !!model.is_share,
|
||||
list: TabMenu.filter((_, idx) => {
|
||||
if (model.is_share) {
|
||||
return true
|
||||
} else {
|
||||
return idx !== 1
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
methods: {
|
||||
goTakePhoto() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/takephoto/takephoto',
|
||||
})
|
||||
},
|
||||
onChange(event) {
|
||||
this.setData({ active: event.detail.value });
|
||||
wx.switchTab({
|
||||
url: this.data.list[event.detail.value].url.startsWith('/')
|
||||
? this.data.list[event.detail.value].url
|
||||
: `/${this.data.list[event.detail.value].url}`,
|
||||
});
|
||||
},
|
||||
|
||||
init() {
|
||||
const page = getCurrentPages().pop();
|
||||
const route = page ? page.route.split('?')[0] : '';
|
||||
const active = this.data.list.findIndex(
|
||||
(item) =>
|
||||
(item.url.startsWith('/') ? item.url.substr(1) : item.url) ===
|
||||
`${route}`,
|
||||
);
|
||||
this.setData({ active });
|
||||
},
|
||||
getPhoneNumber(e) {
|
||||
console.log(e.detail.code) // 动态令牌
|
||||
console.log(e.detail.errMsg) // 回调信息(成功失败都会返回)
|
||||
console.log(e.detail.errno) // 错误码(失败时返回)
|
||||
if (!e.detail.errno) {
|
||||
R.post('/index.php/api/v1/bind_auth_phone', { code: e.detail.code }).then(() => {
|
||||
this.setData({ hasPhone: true })
|
||||
this.goTakePhoto();
|
||||
})
|
||||
} else {
|
||||
// e.detail.errMsg
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
9
custom-tab-bar/index.json
Normal file
9
custom-tab-bar/index.json
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"t-tab-bar": "tdesign-miniprogram/tab-bar/tab-bar",
|
||||
"t-tab-bar-item": "tdesign-miniprogram/tab-bar-item/tab-bar-item",
|
||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||
"t-image": "tdesign-miniprogram/image/image"
|
||||
}
|
||||
}
|
||||
36
custom-tab-bar/index.wxml
Normal file
36
custom-tab-bar/index.wxml
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<view class="tabline">
|
||||
<t-tab-bar value="{{active}}" bindchange="onChange" split="{{false}}">
|
||||
<t-tab-bar-item wx:for="{{list}}" wx:for-item="item" wx:for-index="index" wx:key="index">
|
||||
<view class="{{'custom-tab-bar-wrapper ' + ('tab' + index) + ' ' + (index == active ? 'cur' : '')}}">
|
||||
<t-icon prefix="wr" name="{{item.icon}}" size="40rpx" />
|
||||
<view class="text">{{ item.text }}</view>
|
||||
</view>
|
||||
</t-tab-bar-item>
|
||||
<!-- <t-tab-bar-item>
|
||||
<view class="{{'custom-tab-bar-wrapper ' + ('tab' + 0) + ' ' + (0 == active ? 'cur' : '')}}">
|
||||
<t-icon prefix="wr" name="{{list[0].icon}}" size="40rpx" />
|
||||
<view class="text">{{ list[0].text }}</view>
|
||||
</view>
|
||||
</t-tab-bar-item>
|
||||
<t-tab-bar-item wx:if="{{is_share}}">
|
||||
<view class="{{'custom-tab-bar-wrapper ' + ('tab' + 1) + ' ' + (1 == active ? 'cur' : '')}}">
|
||||
<t-icon prefix="wr" name="{{list[1].icon}}" size="40rpx" />
|
||||
<view class="text">{{ list[1].text }}</view>
|
||||
</view>
|
||||
</t-tab-bar-item>
|
||||
<t-tab-bar-item>
|
||||
<view class="{{'custom-tab-bar-wrapper ' + ('tab' + 2) + ' ' + (2 == active ? 'cur' : '')}}">
|
||||
<t-icon prefix="wr" name="{{list[2].icon}}" size="40rpx" />
|
||||
<view class="text">{{ list[2].text }}</view>
|
||||
</view>
|
||||
</t-tab-bar-item> -->
|
||||
<!-- <view class="camera" bind:tap="goTakePhoto" wx:if="{{hasPhone}}">
|
||||
<t-image loading=" " mode="aspectFill" src="{{cdnHost + '/static/camera.png?v=5'}}" width="29" height="23" />
|
||||
<view class="txt">发现</view>
|
||||
</view>
|
||||
<button open-type="getPhoneNumber" class="camera" bindgetphonenumber="getPhoneNumber" wx:else>
|
||||
<t-image loading=" " mode="aspectFill" src="{{cdnHost + '/static/camera.png?v=5'}}" width="29" height="23" />
|
||||
<view class="txt">发现</view>
|
||||
</button> -->
|
||||
</t-tab-bar>
|
||||
</view>
|
||||
40
custom-tab-bar/index.wxss
Normal file
40
custom-tab-bar/index.wxss
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
.tabline {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
|
||||
.custom-tab-bar-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.text {
|
||||
font-size: 28rpx;
|
||||
padding-left: 10rpx;
|
||||
}
|
||||
|
||||
.camera {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 20rpx;
|
||||
border-radius: 20rpx;
|
||||
height: 78rpx;
|
||||
width: 176rpx;
|
||||
background: linear-gradient(180deg, rgb(74, 137, 254) 0%, rgb(47, 103, 254) 100%);
|
||||
transform: translateX(-50%);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 2;
|
||||
font-size: 28rpx;
|
||||
color: #fff;
|
||||
}
|
||||
.camera .txt{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding-left:10rpx;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.custom-tab-bar-wrapper.cur {
|
||||
color: #2966f5;
|
||||
}
|
||||
3
gitadd.bat
Normal file
3
gitadd.bat
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
git add .
|
||||
git commit -m "f"
|
||||
git push
|
||||
5
jsconfig.json
Normal file
5
jsconfig.json
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": "."
|
||||
}
|
||||
}
|
||||
17
package.json
Normal file
17
package.json
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "@tencent/tdesign-miniprogram-starter-retail",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "app.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"dayjs": "^1.9.3",
|
||||
"tdesign-miniprogram": "^1.4.0",
|
||||
"tslib": "^1.11.1"
|
||||
},
|
||||
"devDependencies": {}
|
||||
}
|
||||
109
pages/createpay/createpay.js
Normal file
109
pages/createpay/createpay.js
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
import C from '../../utils/constant';
|
||||
import * as F from '../../utils/func';
|
||||
import R from '../../utils/request';
|
||||
import ActionSheet, { ActionSheetTheme } from 'tdesign-miniprogram/action-sheet/index';
|
||||
|
||||
Page({
|
||||
data: {
|
||||
price: '',
|
||||
expireDate: F.parseDate(new Date()),
|
||||
dateVisible: false,
|
||||
start: F.parseDate(new Date()),
|
||||
end: F.parseDate(new Date(new Date() * 1 + 24 * 3600 * 366 * 1000 + 1)),
|
||||
filter(type, options) {
|
||||
if (type === 'year') {
|
||||
return options.sort((a, b) => b.value - a.value);
|
||||
}
|
||||
return options;
|
||||
},
|
||||
popupProps: {
|
||||
usingCustomNavbar: true,
|
||||
},
|
||||
buy_type: '',
|
||||
buy_types: [],
|
||||
},
|
||||
onLoad() {
|
||||
R.get('/index.php/api/v1/config_one', { k: 'buy_types' }).then(({ model }) => {
|
||||
this.setData({
|
||||
buy_types: model || [],
|
||||
buy_type: model[0],
|
||||
});
|
||||
});
|
||||
},
|
||||
handleSelected(e) {
|
||||
console.log(e.detail);
|
||||
this.setData({
|
||||
buy_type: e.detail.selected.label,
|
||||
});
|
||||
},
|
||||
handleAction() {
|
||||
ActionSheet.show({
|
||||
theme: ActionSheetTheme.List,
|
||||
selector: '#t-action-sheet',
|
||||
context: this,
|
||||
items: this.data.buy_types.map((item) => ({
|
||||
label: item,
|
||||
})),
|
||||
});
|
||||
},
|
||||
onConfirm(e) {
|
||||
const { value } = e.detail;
|
||||
this.setData({
|
||||
expireDate: value,
|
||||
dateVisible: false,
|
||||
});
|
||||
},
|
||||
showPicker() {
|
||||
this.setData({ dateVisible: true });
|
||||
},
|
||||
onClose() {
|
||||
this.setData({ dateVisible: false });
|
||||
},
|
||||
validate() {
|
||||
const { price, expireDate } = this.data;
|
||||
if (!price) {
|
||||
wx.showToast({ title: '请输入分销金额', icon: 'none' });
|
||||
return false;
|
||||
}
|
||||
if (!/^\d+(\.\d+)?$/.test(price)) {
|
||||
wx.showToast({ title: '请输入正确的金额', icon: 'none' });
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!expireDate) {
|
||||
wx.showToast({ title: '请选择付款有效期', icon: 'none' });
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
share() {
|
||||
if (!this.validate()) return;
|
||||
// TODO: 调用分享接口
|
||||
// console.log('share1', this.data);
|
||||
// wx.showShareMenu({
|
||||
// withShareTicket: true,
|
||||
// menus: ['shareAppMessage']
|
||||
// });
|
||||
},
|
||||
onShareAppMessage(e) {
|
||||
if (!this.validate()) {
|
||||
return {
|
||||
title: '',
|
||||
path: '',
|
||||
imageUrl: '',
|
||||
promise: Promise.reject(),
|
||||
}
|
||||
}
|
||||
const { price, expireDate, buy_type } = this.data;
|
||||
return R.get('/index.php/api/v1/create_share', {
|
||||
price, expireDate, buy_type,
|
||||
}).then(({ model }) => {
|
||||
return {
|
||||
title: model.title,
|
||||
path: model.path || '/pages/sharebuy/sharebuy?id=' + model.id,
|
||||
imageUrl: model.img,
|
||||
promise: Promise.resolve(),
|
||||
};
|
||||
});
|
||||
},
|
||||
});
|
||||
11
pages/createpay/createpay.json
Normal file
11
pages/createpay/createpay.json
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"navigationBarTitleText": "分销",
|
||||
"backgroundTextStyle": "light",
|
||||
"usingComponents": {
|
||||
"t-cell": "tdesign-miniprogram/cell/cell",
|
||||
"t-button": "tdesign-miniprogram/button/button",
|
||||
"t-input": "tdesign-miniprogram/input/input",
|
||||
"t-date-time-picker": "tdesign-miniprogram/date-time-picker/date-time-picker",
|
||||
"t-action-sheet": "tdesign-miniprogram/action-sheet/action-sheet"
|
||||
}
|
||||
}
|
||||
0
pages/createpay/createpay.less
Normal file
0
pages/createpay/createpay.less
Normal file
14
pages/createpay/createpay.wxml
Normal file
14
pages/createpay/createpay.wxml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<view class="container">
|
||||
<view class="form">
|
||||
<t-input label="分销金额" placeholder="请输入分销金额" suffix="元" type="digit" align="right" model:value="{{price}}" />
|
||||
<t-cell title="分销类型" hover note="{{buy_type || '请选择分销类型'}}" arrow bindtap="handleAction" />
|
||||
<t-cell title="付款有效期" hover note="{{expireDate || '请选择付款有效期'}}" arrow bindtap="showPicker" />
|
||||
<!-- <t-input label="分销类型" placeholder="请选择分销类型" align="right" value="{{buy_type}}" bindtap="handleAction" readonly /> -->
|
||||
<!-- <t-input label="付款有效期" placeholder="请选择付款有效期" align="right" value="{{expireDate}}" bindtap="showPicker" readonly /> -->
|
||||
</view>
|
||||
<view class="footer">
|
||||
<t-button theme="primary" open-type="share" block catchtap="share">分享</t-button>
|
||||
</view>
|
||||
<t-action-sheet id="t-action-sheet" usingCustomNavbar bind:selected="handleSelected" />
|
||||
<t-date-time-picker auto-close title="选择日期" visible="{{dateVisible}}" mode="date" default-value="{{expireDate}}" format="YYYY-MM-DD" start="{{start}}" end="{{end}}" filter="{{filter}}" popup-props="{{popupProps}}" bind:confirm="onConfirm" bind:close="onClose" />
|
||||
</view>
|
||||
14
pages/createpay/createpay.wxss
Normal file
14
pages/createpay/createpay.wxss
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
.container {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.form {
|
||||
background: #fff;
|
||||
border-radius: 10rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.footer {
|
||||
margin-top: 40rpx;
|
||||
padding: 0 20rpx;
|
||||
}
|
||||
33
pages/detail/detail.js
Normal file
33
pages/detail/detail.js
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import R from '../../utils/request';
|
||||
import C from '../../utils/constant';
|
||||
Page({
|
||||
|
||||
data: {
|
||||
cdnHost: C.cdnHost,
|
||||
detail: {},
|
||||
user: {},
|
||||
},
|
||||
onLoad(options) {
|
||||
const { id } = options;
|
||||
R.get('/index.php/api/v1/news_detail', { id }).then(({ model }) => {
|
||||
this.setData({
|
||||
detail: {
|
||||
...model.detail,
|
||||
content: (model.detail.content||'').replace(/src\="\/uploads/g, 'src="'+C.cdnHost + '/uploads'),
|
||||
imgs: (model.detail.imgs || '').split(',').filter(o=>!!o),
|
||||
video: model.detail.video ? model.detail.video : '',
|
||||
},
|
||||
user: {
|
||||
...model.user,
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
videoErrorCallback(e) {
|
||||
console.log('视频错误信息:')
|
||||
console.log(e.detail.errMsg)
|
||||
},
|
||||
onShareAppMessage() {
|
||||
|
||||
}
|
||||
})
|
||||
8
pages/detail/detail.json
Normal file
8
pages/detail/detail.json
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"navigationBarTitleText": "详情",
|
||||
"backgroundTextStyle": "light",
|
||||
"usingComponents": {
|
||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||
"t-image": "tdesign-miniprogram/image/image"
|
||||
}
|
||||
}
|
||||
14
pages/detail/detail.wxml
Normal file
14
pages/detail/detail.wxml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<view>
|
||||
<view class="title">{{detail.title}}</view>
|
||||
<view class="info">
|
||||
<view class="time">{{detail.create_time}}</view>
|
||||
<view class="viewcnt">
|
||||
<t-icon name="browse" size="28rpx" color="#b3b5b9"></t-icon>
|
||||
{{detail.view_cnt}}
|
||||
</view>
|
||||
</view>
|
||||
<rich-text class="desc" nodes="{{detail.content}}"></rich-text>
|
||||
<t-image mode="aspectFill" wx:for="{{detail.imgs}}" src="{{cdnHost + item}}" wx:key="item" class="img" shape="round" />
|
||||
<video class="video" wx:if="{{detail.video}}" id="myVideo" src="{{cdnHost + detail.video}}" binderror="videoErrorCallback" show-center-play-btn='{{false}}' show-play-btn="{{true}}" controls></video>
|
||||
<view class="source">来源: {{user.real_name || '三鲤'}}</view>
|
||||
</view>
|
||||
57
pages/detail/detail.wxss
Normal file
57
pages/detail/detail.wxss
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
page {
|
||||
box-sizing: border-box;
|
||||
background-color: #fff;
|
||||
padding: 0 20rpx;
|
||||
padding-top: 20rpx;
|
||||
padding-bottom: calc(env(safe-area-inset-bottom) + 106rpx);
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 34rpx;
|
||||
list-style: square;
|
||||
margin-bottom: 20rpx;
|
||||
color: #363a44;
|
||||
}
|
||||
|
||||
.info {
|
||||
display: flex;
|
||||
font-size: 28rpx;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 60rpx;
|
||||
color: #b3b5b9;
|
||||
}
|
||||
|
||||
.info .viewcnt {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.info .viewcnt .t-icon {
|
||||
margin-right: 12rpx;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.content {
|
||||
word-break: break-all;
|
||||
line-height: 46rpx;
|
||||
font-size: 26rpx;
|
||||
color: #363a44;
|
||||
}
|
||||
|
||||
.img {
|
||||
width: 100%;
|
||||
margin: 20rpx auto;
|
||||
}
|
||||
|
||||
.video {
|
||||
width: 100%;
|
||||
margin: 20rpx auto;
|
||||
}
|
||||
|
||||
.source {
|
||||
font-size: 24rpx;
|
||||
color: #b3b5b9;
|
||||
text-align: left;
|
||||
margin-top: 40rpx;
|
||||
}
|
||||
66
pages/detail_admin/detail.js
Normal file
66
pages/detail_admin/detail.js
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
// pages/detail_admin/detail.js
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
}
|
||||
})
|
||||
2
pages/detail_admin/detail.wxml
Normal file
2
pages/detail_admin/detail.wxml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!--pages/detail_admin/detail.wxml-->
|
||||
<text>pages/detail_admin/detail.wxml</text>
|
||||
107
pages/faxianlist/faxianlist.js
Normal file
107
pages/faxianlist/faxianlist.js
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
import R from '../../utils/request';
|
||||
import C from '../../utils/constant';
|
||||
import * as F from '../../utils/func';
|
||||
Page({
|
||||
|
||||
data: {
|
||||
cdnHost: C.cdnHost,
|
||||
list: [],
|
||||
page: 1,
|
||||
status: '',
|
||||
// money_flag: 'send',
|
||||
listEndText: '',
|
||||
},
|
||||
onShow() {
|
||||
this.getTabBar().init();
|
||||
this.fetchList(1);
|
||||
},
|
||||
onLoad(options) {
|
||||
},
|
||||
goCreate(e) {
|
||||
wx.navigateTo({
|
||||
url: `/pages/createpay/createpay`
|
||||
});
|
||||
},
|
||||
fetchList(page) {
|
||||
const { status } = this.data;
|
||||
// money_flag
|
||||
R.get('/index.php/api/v1/share_list', { page, status }).then(({ model }) => {
|
||||
const list = [];
|
||||
model.forEach(item => {
|
||||
list.push({
|
||||
...item,
|
||||
price: F.formatePrice(item.price),
|
||||
});
|
||||
});
|
||||
if (list.length == 0) {
|
||||
this.setData({ listEndText: '没有更多了' });
|
||||
} else {
|
||||
this.setData({ listEndText: '点击加载更多。。。' });
|
||||
}
|
||||
if (page == 1) {
|
||||
this.setData({ list,page });
|
||||
} else {
|
||||
const list2 = this.data.list.concat(list);
|
||||
this.setData({ list: list2,page });
|
||||
}
|
||||
});
|
||||
// for (let i = 0; i < 20; i++) {
|
||||
// list.push({
|
||||
// id: i,
|
||||
// title: '自动热重载] 已开启代码文件保存后自动热重载自动热重载] 已开启代码文件保存后自动热重载',
|
||||
// image: `${imageCdn}/swiper2.png`,
|
||||
// createTime: '09-12 12:21',
|
||||
// viewCnt: 1922 + i,
|
||||
// });
|
||||
// }
|
||||
// this.setData({
|
||||
// list
|
||||
// })
|
||||
},
|
||||
loadMore() {
|
||||
const { page, listEndText } = this.data;
|
||||
if (listEndText == '点击加载更多。。。') {
|
||||
this.fetchList(page + 1);
|
||||
}
|
||||
},
|
||||
onTabsChange(event) {
|
||||
const v = event.detail.value;
|
||||
this.data.status = v;
|
||||
this.fetchList(1);
|
||||
},
|
||||
// handleSwitchChange(e) {
|
||||
// const { value } = e.detail;
|
||||
// if (value) {
|
||||
// this.data.money_flag = 'send';
|
||||
// } else {
|
||||
// this.data.money_flag = '';
|
||||
// }
|
||||
// this.fetchList(1);
|
||||
// },
|
||||
onReachBottom() {
|
||||
this.loadMore();
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
this.fetchList(1);
|
||||
wx.stopPullDownRefresh();
|
||||
},
|
||||
editRemark(e) {
|
||||
const { id, remark } = e.currentTarget.dataset.detail;
|
||||
const that = this;
|
||||
wx.showModal({
|
||||
title: '备注',
|
||||
content: remark || '',
|
||||
editable: true,
|
||||
success(re) {
|
||||
const remark2 = re.content || '';
|
||||
R.post('/index.php/api/v1/mark', { id, remark: remark2 }).then(() => {
|
||||
that.data.list.find(o => o.id == id).remark = remark2;
|
||||
that.setData({
|
||||
list: [...that.data.list],
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
})
|
||||
13
pages/faxianlist/faxianlist.json
Normal file
13
pages/faxianlist/faxianlist.json
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"navigationBarTitleText": "我的分销",
|
||||
"backgroundTextStyle": "light",
|
||||
"usingComponents": {
|
||||
"t-tabs": "tdesign-miniprogram/tabs/tabs",
|
||||
"t-tab-panel": "tdesign-miniprogram/tab-panel/tab-panel",
|
||||
"t-image": "tdesign-miniprogram/image/image",
|
||||
"t-sticky": "tdesign-miniprogram/sticky/sticky",
|
||||
"t-divider": "tdesign-miniprogram/divider/divider",
|
||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||
"t-footer": "tdesign-miniprogram/footer/footer"
|
||||
}
|
||||
}
|
||||
44
pages/faxianlist/faxianlist.wxml
Normal file
44
pages/faxianlist/faxianlist.wxml
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<view>
|
||||
<!-- <t-sticky offset-top="{{0}}"> -->
|
||||
<!-- <view class="tabs"> -->
|
||||
<!-- <t-tabs defaultValue="{{0}}" bind:change="onTabsChange" t-class="custom-tabs">
|
||||
<t-tab-panel label="全部" value="" />
|
||||
<t-tab-panel label="已支付" value="payed" />
|
||||
<t-tab-panel label="待支付" value="wait_pay" />
|
||||
</t-tabs>
|
||||
<view class="sw"> -->
|
||||
<!-- <t-switch defaultValue="{{false}}" bindchange="handleSwitchChange" size="small" />
|
||||
<view class="txt">已提现</view> -->
|
||||
<!-- </view> -->
|
||||
<!-- </view> -->
|
||||
<!-- </t-sticky> -->
|
||||
<view class="list">
|
||||
<view class="item" wx:for="{{list}}" wx:key="id">
|
||||
<view class="item-main" data-id="{{item.id}}" bind:tap="goDetail">
|
||||
<view class="right">
|
||||
<view class="text">
|
||||
<view>订单号: {{item.order_no || '-'}} 金额: {{item.price}} 元</view>
|
||||
<view wx:if="{{item.name}}">购买信息: {{item.name}} {{item.phone}}</view>
|
||||
<view data-detail="{{item}}" class="remark" bind:tap="editRemark">
|
||||
<t-icon prefix="wr" name="edit" size="40rpx" />
|
||||
备注: {{item.remark || '无'}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="info">
|
||||
<view wx:if="{{item.pay_time}}">支付时间: {{item.pay_time}}</view>
|
||||
<view wx:else>订单时间: {{item.create_time}}</view>
|
||||
<view class="viewcnt init">{{item.buy_type}}</view>
|
||||
<!-- <view class="viewcnt init" wx:if="{{item.status == 'init'}}">待审核</view> -->
|
||||
<!-- <view class="viewcnt resolve" wx:if="{{item.status == 'payed'}}">已支付</view> -->
|
||||
<!-- <view class="viewcnt reject" wx:if="{{item.status == 'wait_pay'}}">待支付</view> -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<t-footer wx:if="{{listEndText}}" text="{{listEndText}}" bind:tap="loadMore"></t-footer>
|
||||
</view>
|
||||
<view class="btn_cre" bind:tap="goCreate">
|
||||
<view>创建</view>
|
||||
<view>分销</view>
|
||||
</view>
|
||||
</view>
|
||||
113
pages/faxianlist/faxianlist.wxss
Normal file
113
pages/faxianlist/faxianlist.wxss
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
page {
|
||||
padding: 0 20rpx;
|
||||
background-color: rgb(245, 246, 247);
|
||||
}
|
||||
|
||||
.tabs {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
background-color: rgb(245, 246, 247);
|
||||
}
|
||||
|
||||
.tabs .t-tabs {
|
||||
width: 60%;
|
||||
background: none !important;
|
||||
}
|
||||
|
||||
.tabs .t-tabs .t-tabs__wrapper {
|
||||
background: none !important;
|
||||
}
|
||||
|
||||
.sw {
|
||||
width: 240rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 32rpx;
|
||||
}
|
||||
|
||||
.sw .txt {
|
||||
padding-left: 16rpx;
|
||||
}
|
||||
|
||||
|
||||
.list {
|
||||
margin-top: 20rpx;
|
||||
padding-bottom: 60rpx;
|
||||
}
|
||||
|
||||
.list .item {
|
||||
border-radius: 16rpx;
|
||||
background-color: #fff;
|
||||
margin-bottom: 20rpx;
|
||||
width: 710rpx;
|
||||
padding-top: 20rpx;
|
||||
}
|
||||
|
||||
.list .item .item-main {
|
||||
display: flex;
|
||||
padding-left: 20rpx;
|
||||
}
|
||||
|
||||
.list .item .item-main .right {
|
||||
flex: 1;
|
||||
padding: 0 32rpx;
|
||||
padding-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.list .item .item-main .right .text {
|
||||
padding-top: 16rpx;
|
||||
font-size: 28rpx;
|
||||
line-height: 46rpx;
|
||||
margin-bottom: 20rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.list .item .item-main .right .info {
|
||||
display: flex;
|
||||
font-size: 24rpx;
|
||||
justify-content: space-between;
|
||||
color: #8f9197;
|
||||
}
|
||||
|
||||
.list .item .item-main .right .info .viewcnt {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 20rpx;
|
||||
}
|
||||
|
||||
.list .item .item-main .right .info .viewcnt.init {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
.list .item .item-main .right .info .viewcnt.resolve {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.list .item .item-main .right .info .viewcnt.reject {
|
||||
color: gray;
|
||||
}
|
||||
.remark{
|
||||
display: flex;
|
||||
}
|
||||
.btn_cre {
|
||||
position: fixed;
|
||||
bottom: 220rpx;
|
||||
right: 20rpx;
|
||||
height: 120rpx;
|
||||
width: 120rpx;
|
||||
border-radius: 50%;
|
||||
background-color: rgb(111, 172, 207);
|
||||
color: #fff;
|
||||
font-size: 26rpx;
|
||||
z-index: 2;
|
||||
padding-top: 26rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.btn_cre view {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-direction: row;
|
||||
text-align: center;
|
||||
}
|
||||
106
pages/home/home.js
Normal file
106
pages/home/home.js
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
import R from '../../utils/request';
|
||||
import C from '../../utils/constant';
|
||||
Page({
|
||||
data: {
|
||||
cdnHost: C.cdnHost,
|
||||
loadFlag: false,
|
||||
swiperList: [],
|
||||
list: [],
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.getTabBar().init();
|
||||
// this.init();
|
||||
this.fetchBanner();
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
R.login().then(() => {
|
||||
this.init();
|
||||
})
|
||||
},
|
||||
fetchBanner() {
|
||||
R.get('/index.php/api/v1/banner_list', {}).then(({ model }) => {
|
||||
const swiperList = [];
|
||||
model.forEach(item => {
|
||||
swiperList.push({
|
||||
...item,
|
||||
value: C.cdnHost + item.img,
|
||||
ariaLabel: item.title,
|
||||
id: item.id,
|
||||
});
|
||||
});
|
||||
if (JSON.stringify(swiperList) != JSON.stringify(this.data.swiperList)) {
|
||||
this.setData({ swiperList });
|
||||
}
|
||||
});
|
||||
},
|
||||
init() {
|
||||
if (this.data.loadFlag) return;
|
||||
this.data.loadFlag = false;
|
||||
this.fetchList(1);
|
||||
this.fetchBanner();
|
||||
},
|
||||
fetchList(page) {
|
||||
R.get('/index.php/api/v1/news_list', { page, pageSize: 5 }).then(({ model }) => {
|
||||
const list = [];
|
||||
model.forEach(item => {
|
||||
list.push({
|
||||
...item,
|
||||
});
|
||||
});
|
||||
this.setData({ list });
|
||||
});
|
||||
},
|
||||
goDetail(e) {
|
||||
const { id } = e.currentTarget.dataset;
|
||||
wx.navigateTo({
|
||||
url: `/pages/detail/detail?id=${id}`
|
||||
});
|
||||
},
|
||||
onSwiperTap(e) {
|
||||
const { index } = e.detail;
|
||||
this.data.swiperList.forEach((o, i) => {
|
||||
if (i == index) {
|
||||
console.log(o)
|
||||
if(o.action_type == 'newsId'){
|
||||
wx.navigateTo({
|
||||
url: '/pages/detail/detail?id=' + o.action_item,
|
||||
});
|
||||
}
|
||||
if(o.action_type == 'url'){
|
||||
wx.navigateTo({
|
||||
url: '/pages/webview/webview?url=' + encodeURIComponent(o.action_item),
|
||||
});
|
||||
}
|
||||
if(o.action_type == 'path'){
|
||||
wx.navigateTo({
|
||||
url: o.action_item,
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
goUrl(e) {
|
||||
const { url } = e.currentTarget.dataset;
|
||||
wx.navigateTo({
|
||||
url
|
||||
});
|
||||
},
|
||||
goMore() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/news_list/home'
|
||||
});
|
||||
},
|
||||
refresh() {
|
||||
this.fetchList(1);
|
||||
this.fetchBanner();
|
||||
wx.showToast({ icon: 'none', title: '刷新成功' });
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
this.init();
|
||||
wx.stopPullDownRefresh();
|
||||
},
|
||||
onShareAppMessage() { },
|
||||
onShareTimeline() { },
|
||||
});
|
||||
12
pages/home/home.json
Normal file
12
pages/home/home.json
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"navigationBarTitleText": "首页",
|
||||
"backgroundTextStyle": "light",
|
||||
"usingComponents": {
|
||||
"t-swiper": "tdesign-miniprogram/swiper/swiper",
|
||||
"t-swiper-nav": "tdesign-miniprogram/swiper-nav/swiper-nav",
|
||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||
"t-image": "tdesign-miniprogram/image/image",
|
||||
"t-divider": "tdesign-miniprogram/divider/divider"
|
||||
},
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
101
pages/home/home.less
Normal file
101
pages/home/home.less
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
page {
|
||||
box-sizing: border-box;
|
||||
background-color: linear-gradient(180deg, #f0f4fc, #fff);
|
||||
padding: 0 20rpx;
|
||||
padding-top: 10rpx;
|
||||
padding-bottom: calc(env(safe-area-inset-bottom) + 106rpx);
|
||||
}
|
||||
|
||||
.title_bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: 32rpx;
|
||||
}
|
||||
|
||||
.title_bar .title {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
||||
background-position: left center;
|
||||
background-size: 100% 100%;
|
||||
font-size: 32rpx;
|
||||
color: rgb(53, 58, 71);
|
||||
height: 34rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-weight: bold;
|
||||
|
||||
.t-icon {
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.title_bar .btn {
|
||||
color: #71737b;
|
||||
font-size: 28rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.title_bar .btn .t-icon {
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
|
||||
.list {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.list .item .item-main {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.list .item .item-main .right {
|
||||
flex: 1;
|
||||
padding-left: 32rpx;
|
||||
}
|
||||
|
||||
.list .item .item-main .right .text {
|
||||
padding-top: 0rpx;
|
||||
font-size: 28rpx;
|
||||
line-height: 46rpx;
|
||||
margin-bottom: 10rpx;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: #363a44;
|
||||
|
||||
}
|
||||
|
||||
.list .item .item-main .right .info {
|
||||
display: flex;
|
||||
font-size: 24rpx;
|
||||
justify-content: space-between;
|
||||
color: #71737b;
|
||||
}
|
||||
|
||||
.list .item .item-main .right .info .viewcnt {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.list .item .viewcnt .t-icon {
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
|
||||
.t-tab-bar {
|
||||
border-top: 1px solid #eee;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.activity {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 20rpx 0;
|
||||
border-bottom: 1px solid #eee;
|
||||
|
||||
.t-image {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
31
pages/home/home.wxml
Normal file
31
pages/home/home.wxml
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<view>
|
||||
<t-swiper wx:if="{{swiperList.length > 0}}" current="{{current}}" autoplay="{{true}}" duration="{{500}}" height="{{180}}" interval="{{3000}}" list="{{swiperList}}" navigation="{{ { type: 'dots-bar' } }}" bind:click="onSwiperTap" />
|
||||
<view class="title_bar" wx:if="{{list.length}}">
|
||||
<view class="title" bind:tap="refresh">
|
||||
公司动态
|
||||
<t-icon name="refresh" size="28rpx" color="71737b"></t-icon>
|
||||
</view>
|
||||
<view class="btn" bind:tap="goMore">
|
||||
查看全部
|
||||
<t-icon name="chevron-right" size="28rpx" color="71737b"></t-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="list" wx:if="{{list.length}}">
|
||||
<view class="item" wx:for="{{list}}" wx:key="id">
|
||||
<view class="item-main" data-id="{{item.id}}" bind:tap="goDetail">
|
||||
<t-image mode="aspectFill" src="{{cdnHost+item.poster}}" width="108" height="72" shape="round" />
|
||||
<view class="right">
|
||||
<view class="text">{{item.title}}</view>
|
||||
<view class="info">
|
||||
<view>{{item.create_time}}</view>
|
||||
<view class="viewcnt">
|
||||
<t-icon name="browse" size="28rpx" color="71737b"></t-icon>
|
||||
{{item.view_cnt}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<t-divider />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
84
pages/home/home.wxss
Normal file
84
pages/home/home.wxss
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
page {
|
||||
box-sizing: border-box;
|
||||
background-color: linear-gradient(180deg, #f0f4fc, #fff);
|
||||
padding: 0 20rpx;
|
||||
padding-top: 10rpx;
|
||||
padding-bottom: calc(env(safe-area-inset-bottom) + 106rpx);
|
||||
}
|
||||
.title_bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: 32rpx;
|
||||
}
|
||||
.title_bar .title {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
||||
background-position: left center;
|
||||
background-size: 100% 100%;
|
||||
font-size: 32rpx;
|
||||
color: #353a47;
|
||||
height: 34rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-weight: bold;
|
||||
}
|
||||
.title_bar .title .t-icon {
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
.title_bar .btn {
|
||||
color: #71737b;
|
||||
font-size: 28rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.title_bar .btn .t-icon {
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
.list {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
.list .item .item-main {
|
||||
display: flex;
|
||||
}
|
||||
.list .item .item-main .right {
|
||||
flex: 1;
|
||||
padding-left: 32rpx;
|
||||
}
|
||||
.list .item .item-main .right .text {
|
||||
padding-top: 0rpx;
|
||||
font-size: 28rpx;
|
||||
line-height: 46rpx;
|
||||
margin-bottom: 10rpx;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: #363a44;
|
||||
}
|
||||
.list .item .item-main .right .info {
|
||||
display: flex;
|
||||
font-size: 24rpx;
|
||||
justify-content: space-between;
|
||||
color: #71737b;
|
||||
}
|
||||
.list .item .item-main .right .info .viewcnt {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.list .item .viewcnt .t-icon {
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
.t-tab-bar {
|
||||
border-top: 1px solid #eee;
|
||||
position: relative;
|
||||
}
|
||||
.activity {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 20rpx 0;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
.activity .t-image {
|
||||
width: 100%;
|
||||
}
|
||||
8
pages/home/readme
Normal file
8
pages/home/readme
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
首页功能设定
|
||||
1. loading入场
|
||||
2. 下拉刷新
|
||||
3. 搜索栏
|
||||
4. 分类切换
|
||||
5. 商品列表
|
||||
6. 规格弹层
|
||||
7. 加载更多
|
||||
66
pages/news_admin_list/home.js
Normal file
66
pages/news_admin_list/home.js
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
// pages/news_admin_list/home.js
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
}
|
||||
})
|
||||
2
pages/news_admin_list/home.wxml
Normal file
2
pages/news_admin_list/home.wxml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!--pages/news_admin_list/home.wxml-->
|
||||
<text>pages/news_admin_list/home.wxml</text>
|
||||
63
pages/news_list/home.js
Normal file
63
pages/news_list/home.js
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
import R from '../../utils/request';
|
||||
import C from '../../utils/constant';
|
||||
Page({
|
||||
data: {
|
||||
cdnHost: C.cdnHost,
|
||||
list: [],
|
||||
page: 1,
|
||||
listEndText: '',
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.getTabBar().init();
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.init();
|
||||
},
|
||||
init() {
|
||||
this.fetchList(1);
|
||||
},
|
||||
fetchList(page) {
|
||||
R.get('/index.php/api/v1/news_list', { page }).then(({ model }) => {
|
||||
const list = [];
|
||||
model.forEach(item => {
|
||||
list.push({
|
||||
...item,
|
||||
});
|
||||
});
|
||||
if (list.length == 0) {
|
||||
this.setData({ listEndText: '没有更多了' });
|
||||
} else {
|
||||
this.setData({ listEndText: '点击加载更多。。。' });
|
||||
}
|
||||
if (page == 1) {
|
||||
this.setData({ list ,page});
|
||||
} else {
|
||||
const list2 = this.data.list.concat(list);
|
||||
this.setData({ list: list2,page });
|
||||
}
|
||||
});
|
||||
},
|
||||
loadMore() {
|
||||
const { page, listEndText } = this.data;
|
||||
if (listEndText == '点击加载更多。。。') {
|
||||
this.fetchList(page + 1);
|
||||
}
|
||||
},
|
||||
goDetail(e) {
|
||||
const { id } = e.currentTarget.dataset;
|
||||
wx.navigateTo({
|
||||
url: `/pages/detail/detail?id=${id}`
|
||||
});
|
||||
},
|
||||
refresh() {
|
||||
this.fetchList(1);
|
||||
wx.showToast({ icon: 'none', title: '刷新成功' });
|
||||
},
|
||||
// 下拉刷新
|
||||
onPullDownRefresh() {
|
||||
this.init();
|
||||
wx.stopPullDownRefresh();
|
||||
},
|
||||
});
|
||||
10
pages/news_list/home.json
Normal file
10
pages/news_list/home.json
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"navigationBarTitleText": "发现",
|
||||
"backgroundTextStyle": "light",
|
||||
"usingComponents": {
|
||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||
"t-image": "tdesign-miniprogram/image/image",
|
||||
"t-divider": "tdesign-miniprogram/divider/divider",
|
||||
"t-footer": "tdesign-miniprogram/footer/footer"
|
||||
}
|
||||
}
|
||||
95
pages/news_list/home.less
Normal file
95
pages/news_list/home.less
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
page {
|
||||
box-sizing: border-box;
|
||||
background-color: linear-gradient(180deg, #f0f4fc, #fff);
|
||||
padding: 0 20rpx;
|
||||
padding-top: 10rpx;
|
||||
padding-bottom: calc(env(safe-area-inset-bottom) + 106rpx);
|
||||
}
|
||||
|
||||
.title_bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: 32rpx;
|
||||
}
|
||||
|
||||
.title_bar .title {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
||||
// background: url('http://cdn.zhonganonline.top/newslist/static/title.png') no-repeat;
|
||||
background-position: left center;
|
||||
background-size: 100% 100%;
|
||||
font-size: 32rpx;
|
||||
height: 34rpx;
|
||||
width: 132rpx;
|
||||
}
|
||||
|
||||
|
||||
.title_bar .btn {
|
||||
color: #71737b;
|
||||
font-size: 28rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.title_bar .btn .t-icon {
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
|
||||
.list {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.list .item .item-main {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.list .item .item-main .right {
|
||||
flex: 1;
|
||||
padding-left: 32rpx;
|
||||
}
|
||||
|
||||
.list .item .item-main .right .text {
|
||||
padding-top: 0rpx;
|
||||
font-size: 28rpx;
|
||||
line-height: 46rpx;
|
||||
margin-bottom: 10rpx;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: #363a44;
|
||||
|
||||
}
|
||||
|
||||
.list .item .item-main .right .info {
|
||||
display: flex;
|
||||
font-size: 24rpx;
|
||||
justify-content: space-between;
|
||||
color: #71737b;
|
||||
}
|
||||
|
||||
.list .item .item-main .right .info .viewcnt {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.list .item .viewcnt .t-icon {
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
|
||||
.t-tab-bar {
|
||||
border-top: 1px solid #eee;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.activity {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 20rpx 0;
|
||||
border-bottom: 1px solid #eee;
|
||||
|
||||
.t-image {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
28
pages/news_list/home.wxml
Normal file
28
pages/news_list/home.wxml
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<view>
|
||||
<view class="title_bar">
|
||||
<view class="title">最新动态</view>
|
||||
<view class="btn" bind:tap="refresh">
|
||||
<t-icon name="refresh" size="28rpx" color="71737b"></t-icon>
|
||||
刷新
|
||||
</view>
|
||||
</view>
|
||||
<view class="list">
|
||||
<view class="item" wx:for="{{list}}" wx:key="id">
|
||||
<view class="item-main" data-id="{{item.id}}" bind:tap="goDetail">
|
||||
<t-image mode="aspectFill" src="{{cdnHost+item.poster}}" width="108" height="72" shape="round" />
|
||||
<view class="right">
|
||||
<view class="text">{{item.title}}</view>
|
||||
<view class="info">
|
||||
<view>{{item.create_time}}</view>
|
||||
<view class="viewcnt">
|
||||
<t-icon name="browse" size="28rpx" color="71737b"></t-icon>
|
||||
{{item.view_cnt}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<t-divider />
|
||||
</view>
|
||||
<t-footer wx:if="{{listEndText}}" text="{{listEndText}}" bind:tap="loadMore"></t-footer>
|
||||
</view>
|
||||
</view>
|
||||
78
pages/news_list/home.wxss
Normal file
78
pages/news_list/home.wxss
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
page {
|
||||
box-sizing: border-box;
|
||||
background-color: linear-gradient(180deg, #f0f4fc, #fff);
|
||||
padding: 0 20rpx;
|
||||
padding-top: 10rpx;
|
||||
padding-bottom: calc(env(safe-area-inset-bottom) + 106rpx);
|
||||
}
|
||||
.title_bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: 32rpx;
|
||||
}
|
||||
.title_bar .title {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
||||
background-position: left center;
|
||||
background-size: 100% 100%;
|
||||
font-size: 32rpx;
|
||||
height: 34rpx;
|
||||
width: 132rpx;
|
||||
}
|
||||
.title_bar .btn {
|
||||
color: #71737b;
|
||||
font-size: 28rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.title_bar .btn .t-icon {
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
.list {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
.list .item .item-main {
|
||||
display: flex;
|
||||
}
|
||||
.list .item .item-main .right {
|
||||
flex: 1;
|
||||
padding-left: 32rpx;
|
||||
}
|
||||
.list .item .item-main .right .text {
|
||||
padding-top: 0rpx;
|
||||
font-size: 28rpx;
|
||||
line-height: 46rpx;
|
||||
margin-bottom: 10rpx;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: #363a44;
|
||||
}
|
||||
.list .item .item-main .right .info {
|
||||
display: flex;
|
||||
font-size: 24rpx;
|
||||
justify-content: space-between;
|
||||
color: #71737b;
|
||||
}
|
||||
.list .item .item-main .right .info .viewcnt {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.list .item .viewcnt .t-icon {
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
.t-tab-bar {
|
||||
border-top: 1px solid #eee;
|
||||
position: relative;
|
||||
}
|
||||
.activity {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 20rpx 0;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
.activity .t-image {
|
||||
width: 100%;
|
||||
}
|
||||
8
pages/news_list/readme
Normal file
8
pages/news_list/readme
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
首页功能设定
|
||||
1. loading入场
|
||||
2. 下拉刷新
|
||||
3. 搜索栏
|
||||
4. 分类切换
|
||||
5. 商品列表
|
||||
6. 规格弹层
|
||||
7. 加载更多
|
||||
39
pages/pay/pay.js
Normal file
39
pages/pay/pay.js
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import R from '../../utils/request';
|
||||
import C from '../../utils/constant';
|
||||
import * as F from '../../utils/func';
|
||||
Page({
|
||||
data: {
|
||||
|
||||
},
|
||||
onLoad(options) {
|
||||
const { order_no, redirect_url } = options;
|
||||
|
||||
R.post('/index.php/api/v1/pay_order_shop', { order_no }).then(({ model }) => {
|
||||
wx.requestPayment({
|
||||
...model,
|
||||
success(res) {
|
||||
wx.showToast({
|
||||
title: '支付成功',
|
||||
icon: 'success',
|
||||
duration: 2000,
|
||||
success() {
|
||||
wx.redirectTo({
|
||||
url: '/pages/shop/shop?path=user',
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
fail(res) {
|
||||
wx.showToast({
|
||||
title: '支付失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
wx.redirectTo({
|
||||
url: '/pages/shop/shop?path=user',
|
||||
});
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
})
|
||||
5
pages/pay/pay.json
Normal file
5
pages/pay/pay.json
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"navigationBarTitleText": "支付",
|
||||
"backgroundTextStyle": "light",
|
||||
"usingComponents": {}
|
||||
}
|
||||
1
pages/pay/pay.wxml
Normal file
1
pages/pay/pay.wxml
Normal file
|
|
@ -0,0 +1 @@
|
|||
<view class="tip">支付中...</view>
|
||||
4
pages/pay/pay.wxss
Normal file
4
pages/pay/pay.wxss
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
.tip {
|
||||
text-align: center;
|
||||
margin-top: 20px;
|
||||
}
|
||||
105
pages/paylist/paylist.js
Normal file
105
pages/paylist/paylist.js
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
import R from '../../utils/request';
|
||||
import C from '../../utils/constant';
|
||||
import * as F from '../../utils/func';
|
||||
Page({
|
||||
|
||||
data: {
|
||||
cdnHost: C.cdnHost,
|
||||
list: [],
|
||||
page: 1,
|
||||
status: '',
|
||||
// money_flag: 'send',
|
||||
listEndText: '',
|
||||
},
|
||||
onLoad(options) {
|
||||
const {from} = options;
|
||||
if(from == 'sharebuy') {
|
||||
R.post('/index.php/api/v1/configs',{ks:['payed_tip','payed_vip_link']}).then(({model})=>{
|
||||
if(model.payed_tip && model.payed_vip_link) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: model.payed_tip,
|
||||
complete: (res) => {
|
||||
if (res.confirm) {
|
||||
wx.navigateTo({
|
||||
url: '/pages/webview/webview?url=' + encodeURIComponent(model.payed_vip_link),
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
this.fetchList(1);
|
||||
},
|
||||
goDetail(e) {
|
||||
const { detail } = e.currentTarget.dataset;
|
||||
if (!detail.phone && detail.status == 'payed') {
|
||||
wx.navigateTo({
|
||||
url: `/pages/sharebuy/sharebuy?id=${detail.share_id}&orderNo=${detail.order_no}`,
|
||||
});
|
||||
}
|
||||
},
|
||||
fetchList(page) {
|
||||
const { status } = this.data;
|
||||
// money_flag
|
||||
R.get('/index.php/api/v1/order_list', { page }).then(({ model }) => {
|
||||
const list = [];
|
||||
model.forEach(item => {
|
||||
list.push({
|
||||
...item,
|
||||
price: F.formatePrice(item.price),
|
||||
});
|
||||
});
|
||||
if (list.length == 0) {
|
||||
this.setData({ listEndText: '没有更多了' });
|
||||
} else {
|
||||
this.setData({ listEndText: '点击加载更多。。。' });
|
||||
}
|
||||
if (page == 1) {
|
||||
this.setData({ list,page });
|
||||
} else {
|
||||
const list2 = this.data.list.concat(list);
|
||||
this.setData({ list: list2,page });
|
||||
}
|
||||
});
|
||||
// for (let i = 0; i < 20; i++) {
|
||||
// list.push({
|
||||
// id: i,
|
||||
// title: '自动热重载] 已开启代码文件保存后自动热重载自动热重载] 已开启代码文件保存后自动热重载',
|
||||
// image: `${imageCdn}/swiper2.png`,
|
||||
// createTime: '09-12 12:21',
|
||||
// viewCnt: 1922 + i,
|
||||
// });
|
||||
// }
|
||||
// this.setData({
|
||||
// list
|
||||
// })
|
||||
},
|
||||
loadMore() {
|
||||
const { page, listEndText } = this.data;
|
||||
if (listEndText == '点击加载更多。。。') {
|
||||
this.fetchList(page + 1);
|
||||
}
|
||||
},
|
||||
onTabsChange(event) {
|
||||
const v = event.detail.value;
|
||||
this.data.status = v;
|
||||
this.fetchList(1);
|
||||
},
|
||||
// handleSwitchChange(e) {
|
||||
// const { value } = e.detail;
|
||||
// if (value) {
|
||||
// this.data.money_flag = 'send';
|
||||
// } else {
|
||||
// this.data.money_flag = '';
|
||||
// }
|
||||
// this.fetchList(1);
|
||||
// },
|
||||
onReachBottom() {
|
||||
this.loadMore();
|
||||
},
|
||||
onShareAppMessage() {
|
||||
}
|
||||
})
|
||||
12
pages/paylist/paylist.json
Normal file
12
pages/paylist/paylist.json
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"navigationBarTitleText": "我的订单",
|
||||
"backgroundTextStyle": "light",
|
||||
"usingComponents": {
|
||||
"t-tabs": "tdesign-miniprogram/tabs/tabs",
|
||||
"t-tab-panel": "tdesign-miniprogram/tab-panel/tab-panel",
|
||||
"t-image": "tdesign-miniprogram/image/image",
|
||||
"t-sticky": "tdesign-miniprogram/sticky/sticky",
|
||||
"t-divider": "tdesign-miniprogram/divider/divider",
|
||||
"t-footer": "tdesign-miniprogram/footer/footer"
|
||||
}
|
||||
}
|
||||
31
pages/paylist/paylist.wxml
Normal file
31
pages/paylist/paylist.wxml
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<view>
|
||||
<view class="list">
|
||||
<view class="item" wx:for="{{list}}" wx:key="id">
|
||||
<view class="item-main" data-detail="{{item}}" bind:tap="goDetail">
|
||||
<view class="right">
|
||||
<view class="text">
|
||||
<view>订单号: {{item.order_no || '-'}}</view>
|
||||
<view>{{item.price}}元</view>
|
||||
</view>
|
||||
<view class="info" wx:if="{{!item.phone}}">
|
||||
<view>{{item.buy_type}}</view>
|
||||
<view style="text-align: right;color:coral">补充信息{{' >'}}</view>
|
||||
</view>
|
||||
<view class="info" wx:if="{{item.phone}}">
|
||||
<view>信息: {{item.name || '暂无'}} {{item.phone}}</view>
|
||||
<view style="text-align: right;">{{item.buy_type}}</view>
|
||||
</view>
|
||||
<view class="info">
|
||||
<view wx:if="{{item.pay_time}}">支付时间: {{item.pay_time}}</view>
|
||||
<view wx:else>订单时间: {{item.create_time}}</view>
|
||||
<!-- <view class="viewcnt init">{{item.buy_type}}</view> -->
|
||||
<!-- <view class="viewcnt init" wx:if="{{item.status == 'init'}}">待审核</view> -->
|
||||
<view class="viewcnt resolve" wx:if="{{item.status == 'payed'}}">已支付</view>
|
||||
<view class="viewcnt reject" wx:if="{{item.status == 'wait_pay'}}">待支付</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<t-footer wx:if="{{listEndText}}" text="{{listEndText}}" bind:tap="loadMore"></t-footer>
|
||||
</view>
|
||||
</view>
|
||||
76
pages/paylist/paylist.wxss
Normal file
76
pages/paylist/paylist.wxss
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
page {
|
||||
padding: 0 20rpx;
|
||||
background-color: rgb(245, 246, 247);
|
||||
}
|
||||
.sw {
|
||||
width: 240rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 32rpx;
|
||||
}
|
||||
|
||||
.sw .txt {
|
||||
padding-left: 16rpx;
|
||||
}
|
||||
|
||||
|
||||
.list {
|
||||
margin-top: 20rpx;
|
||||
padding-bottom: 60rpx;
|
||||
}
|
||||
|
||||
.list .item {
|
||||
border-radius: 16rpx;
|
||||
background-color: #fff;
|
||||
margin-bottom: 20rpx;
|
||||
width: 710rpx;
|
||||
padding-top: 20rpx;
|
||||
}
|
||||
|
||||
.list .item .item-main {
|
||||
display: flex;
|
||||
padding-left: 20rpx;
|
||||
}
|
||||
|
||||
.list .item .item-main .right {
|
||||
flex: 1;
|
||||
padding: 0 32rpx;
|
||||
padding-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.list .item .item-main .right .text {
|
||||
display: flex;
|
||||
font-size: 28rpx;
|
||||
justify-content: space-between;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.list .item .item-main .right .info {
|
||||
display: flex;
|
||||
font-size: 24rpx;
|
||||
justify-content: space-between;
|
||||
color: #8f9197;
|
||||
line-height: 36rpx;
|
||||
}
|
||||
|
||||
.list .item .item-main .right .info .viewcnt {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 20rpx;
|
||||
}
|
||||
|
||||
.list .item .item-main .right .info .viewcnt.init {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
.list .item .item-main .right .info .viewcnt.resolve {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.list .item .item-main .right .info .viewcnt.reject {
|
||||
color: gray;
|
||||
}
|
||||
|
||||
.list .item .h20 {
|
||||
height: 20rpx;
|
||||
}
|
||||
141
pages/sharebuy/sharebuy.js
Normal file
141
pages/sharebuy/sharebuy.js
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
import C from '../../utils/constant';
|
||||
import * as F from '../../utils/func';
|
||||
import R from '../../utils/request';
|
||||
Page({
|
||||
data: {
|
||||
expireDate: '',
|
||||
price: '',
|
||||
shareId: '',
|
||||
isPay: false,
|
||||
orderNo: '',
|
||||
phone: '',
|
||||
username: '',
|
||||
tip_before_pay: '',
|
||||
tip_after_pay: '',
|
||||
buy_type: '',
|
||||
},
|
||||
onLoad(options) {
|
||||
const { id, orderNo } = options;
|
||||
if (orderNo) {
|
||||
this.setData({
|
||||
isPay: true,
|
||||
orderNo,
|
||||
})
|
||||
this.fetchOrder(orderNo);
|
||||
} else {
|
||||
R.get('/index.php/api/v1/get_share', { id }).then(({ model }) => {
|
||||
this.setData({
|
||||
shareId: id,
|
||||
price: F.formatePrice(model.price),
|
||||
expireDate: model.expire_time,
|
||||
tip_before_pay: model.tip_before_pay || '',
|
||||
tip_after_pay: model.tip_after_pay || '',
|
||||
buy_type: model.buy_type,
|
||||
});
|
||||
}).catch((e)=>{
|
||||
console.log('xxx',e);
|
||||
})
|
||||
R.get('/index.php/api/v1/view_share', { id });
|
||||
}
|
||||
},
|
||||
refresh() {
|
||||
if (this.data.orderNo) {
|
||||
this.fetchOrder(this.data.orderNo);
|
||||
}
|
||||
},
|
||||
fetchOrder(orderNo) {
|
||||
const that = this;
|
||||
return R.get('/index.php/api/v1/fetch_order_pay', { order_no: orderNo }).then(({ model }) => {
|
||||
console.log('payed', model);
|
||||
if (model.status === 'payed') {
|
||||
clearInterval(that.data.timer);
|
||||
wx.hideLoading();
|
||||
this.setData({
|
||||
isPay: true,
|
||||
orderNo,
|
||||
price: F.formatePrice(model.price),
|
||||
buy_type: model.buy_type,
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
checkOrderStatus(orderNo) {
|
||||
wx.showLoading({
|
||||
title: '确认支付中...',
|
||||
})
|
||||
this.data.timer = setInterval(() => {
|
||||
this.fetchOrder(orderNo).catch(() => {
|
||||
clearInterval(this.data.timer);
|
||||
});
|
||||
}, 1000);
|
||||
},
|
||||
goPay() {
|
||||
const that = this;
|
||||
if (this.data.shareId) {
|
||||
R.post('/index.php/api/v1/make_order', { share_id: this.data.shareId }).then(({ model: { order_no } }) => {
|
||||
that.data.orderNo = order_no;
|
||||
R.post('/index.php/api/v1/pay_order', { order_no }).then(({ model }) => {
|
||||
wx.requestPayment({
|
||||
...model,
|
||||
success(res) {
|
||||
wx.showToast({
|
||||
title: '支付成功',
|
||||
icon: 'success',
|
||||
duration: 2000,
|
||||
success() {
|
||||
that.checkOrderStatus(order_no);
|
||||
// this.setData({
|
||||
// isPay: true,
|
||||
// })
|
||||
}
|
||||
})
|
||||
},
|
||||
fail(res) {
|
||||
wx.showToast({
|
||||
title: '您已取消支付',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
// wx.redirectTo({
|
||||
// url: '/pages/shop/shop?path=user',
|
||||
// });
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
onShareAppMessage() {
|
||||
|
||||
},
|
||||
validate() {
|
||||
const { username, phone, orderNo, } = this.data;
|
||||
if (!username) {
|
||||
wx.showToast({ title: '请输入姓名', icon: 'none' });
|
||||
return false;
|
||||
}
|
||||
if (!/^1\d{10}$/.test(phone)) {
|
||||
wx.showToast({ title: '请输入正确的手机号', icon: 'none' });
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
submit() {
|
||||
if (!this.validate()) return;
|
||||
const {
|
||||
username, phone, orderNo,
|
||||
} = this.data
|
||||
R.post('/index.php/api/v1/mark_order_info', { name: username, phone, order_no: orderNo, }).then(({ model }) => {
|
||||
wx.showToast({
|
||||
title: '提交成功',
|
||||
icon: 'success',
|
||||
duration: 2000,
|
||||
success() {
|
||||
wx.redirectTo({
|
||||
url: '/pages/paylist/paylist?from=sharebuy',
|
||||
})
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
})
|
||||
9
pages/sharebuy/sharebuy.json
Normal file
9
pages/sharebuy/sharebuy.json
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"navigationBarTitleText": "支付",
|
||||
"backgroundTextStyle": "light",
|
||||
"usingComponents": {
|
||||
"t-cell": "tdesign-miniprogram/cell/cell",
|
||||
"t-button": "tdesign-miniprogram/button/button",
|
||||
"t-input": "tdesign-miniprogram/input/input"
|
||||
}
|
||||
}
|
||||
57
pages/sharebuy/sharebuy.less
Normal file
57
pages/sharebuy/sharebuy.less
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
page {
|
||||
box-sizing: border-box;
|
||||
background-color: linear-gradient(180deg, #f0f4fc, #fff);
|
||||
padding: 0 20rpx;
|
||||
padding-top: 10rpx;
|
||||
padding-bottom: calc(env(safe-area-inset-bottom) + 106rpx);
|
||||
}
|
||||
|
||||
.logo {
|
||||
height: 180rpx;
|
||||
width: 180rpx;
|
||||
margin: 0 auto;
|
||||
background-image: url('http://cdn.zhonganonline.top/liiistem/static/liii_icon.png');
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
.form {
|
||||
background: #fff;
|
||||
border-radius: 10rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.footer {
|
||||
margin-top: 40rpx;
|
||||
padding: 0 20rpx;
|
||||
}
|
||||
|
||||
.card {
|
||||
margin: 20rpx 0;
|
||||
padding: 0 20rpx;
|
||||
|
||||
.line {
|
||||
font-size: 36rpx;
|
||||
line-height: 60rpx;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
.ma {
|
||||
height: 20rpx;
|
||||
}
|
||||
|
||||
.desc {
|
||||
color: #666;
|
||||
font-size: 28rpx;
|
||||
margin-top: 20rpx;
|
||||
line-height: 34rpx;
|
||||
}
|
||||
|
||||
.refresh{
|
||||
text-align: center;
|
||||
margin-top: 20rpx;
|
||||
color: #999;
|
||||
}
|
||||
37
pages/sharebuy/sharebuy.wxml
Normal file
37
pages/sharebuy/sharebuy.wxml
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<view class="logo"></view>
|
||||
<view class="card" wx:if="{{!isPay}}">
|
||||
<!-- <view class="line">付款: {{price}}元</view>
|
||||
<view class="line">付款有效期: {{expireDate}}</view> -->
|
||||
<t-cell title="付款" hover note="{{price}}元" />
|
||||
<t-cell title="有效期" hover note="{{expireDate}}" />
|
||||
<t-cell title="类型" hover note="{{buy_type}}" />
|
||||
<view class="ma"></view>
|
||||
<t-button theme="primary" size="large" block bind:tap="goPay">立即付款</t-button>
|
||||
<view class="refresh" bind:tap="refresh">已支付? 手动刷新</view>
|
||||
<view class="ma"></view>
|
||||
<view class="ma"></view>
|
||||
<view wx:if="{{tip_before_pay}}">
|
||||
<!-- <view>支付提示:</view> -->
|
||||
<rich-text class="desc" nodes="{{tip_before_pay}}"></rich-text>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:else>
|
||||
<!-- <view>付款订单号: {{orderNo}}</view> -->
|
||||
<!-- <view>付款成功: {{price}}元</view> -->
|
||||
<t-cell title="付款订单号" hover note="{{orderNo}}" />
|
||||
<t-cell title="类型" hover note="{{buy_type}}" />
|
||||
<t-cell title="付款成功" hover note="{{price}}元" />
|
||||
<view class="ma"></view>
|
||||
<view class="form">
|
||||
<t-input label="姓名" placeholder="请输入姓名" model:value="{{username}}" />
|
||||
<t-input label="电话" placeholder="请输入电话" type="digit" model:value="{{phone}}" />
|
||||
</view>
|
||||
<view class="footer">
|
||||
<t-button theme="primary" block catchtap="submit">提交</t-button>
|
||||
</view>
|
||||
<view class="ma"></view>
|
||||
<view class="ma"></view>
|
||||
<view wx:if="{{tip_after_pay}}">
|
||||
<rich-text class="desc" nodes="{{tip_after_pay}}"></rich-text>
|
||||
</view>
|
||||
</view>
|
||||
48
pages/sharebuy/sharebuy.wxss
Normal file
48
pages/sharebuy/sharebuy.wxss
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
page {
|
||||
box-sizing: border-box;
|
||||
background-color: linear-gradient(180deg, #f0f4fc, #fff);
|
||||
padding: 0 20rpx;
|
||||
padding-top: 10rpx;
|
||||
padding-bottom: calc(env(safe-area-inset-bottom) + 106rpx);
|
||||
}
|
||||
.logo {
|
||||
height: 180rpx;
|
||||
width: 180rpx;
|
||||
margin: 0 auto;
|
||||
background-image: url('http://cdn.zhonganonline.top/liiistem/static/liii_icon.png');
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
background-size: cover;
|
||||
}
|
||||
.form {
|
||||
background: #fff;
|
||||
border-radius: 10rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
.footer {
|
||||
margin-top: 40rpx;
|
||||
padding: 0 20rpx;
|
||||
}
|
||||
.card {
|
||||
margin: 20rpx 0;
|
||||
padding: 0 20rpx;
|
||||
}
|
||||
.card .line {
|
||||
font-size: 36rpx;
|
||||
line-height: 60rpx;
|
||||
}
|
||||
.ma {
|
||||
height: 20rpx;
|
||||
}
|
||||
.desc {
|
||||
color: #666;
|
||||
font-size: 28rpx;
|
||||
margin-top: 20rpx;
|
||||
line-height: 34rpx;
|
||||
}
|
||||
|
||||
.refresh{
|
||||
text-align: center;
|
||||
margin-top: 20rpx;
|
||||
color: #999;
|
||||
}
|
||||
77
pages/sharelist/sharelist.js
Normal file
77
pages/sharelist/sharelist.js
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
import R from '../../utils/request';
|
||||
import C from '../../utils/constant';
|
||||
import * as F from '../../utils/func';
|
||||
Page({
|
||||
|
||||
data: {
|
||||
cdnHost: C.cdnHost,
|
||||
list: [],
|
||||
page: 1,
|
||||
status: '',
|
||||
// money_flag: 'send',
|
||||
listEndText: '',
|
||||
},
|
||||
onLoad(options) {
|
||||
this.fetchList(1);
|
||||
},
|
||||
goDel(e) {
|
||||
const {detail,index} =e.currentTarget.dataset;
|
||||
if(detail.deleted == 1) return;
|
||||
const {id}=detail;
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '置为失效后无法恢复,确认继续吗?',
|
||||
complete: (res) => {
|
||||
if (res.cancel) {
|
||||
|
||||
}
|
||||
|
||||
if (res.confirm) {
|
||||
R.post('/index.php/api/v1/del_share',{id}).then(()=>{
|
||||
const {list} = this.data;
|
||||
this.setData({
|
||||
[`list[${index}]`] : {
|
||||
...list[index],
|
||||
deleted:1,
|
||||
},
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
fetchList(page) {
|
||||
const { status } = this.data;
|
||||
// money_flag
|
||||
R.get('/index.php/api/v1/share_link_list', { page }).then(({ model }) => {
|
||||
const list = [];
|
||||
model.forEach(item => {
|
||||
list.push({
|
||||
...item,
|
||||
price: F.formatePrice(item.price),
|
||||
expire_time: item.expire_time.split(' ')[0],
|
||||
});
|
||||
});
|
||||
if (list.length == 0) {
|
||||
this.setData({ listEndText: '没有更多了' });
|
||||
} else {
|
||||
this.setData({ listEndText: '点击加载更多。。。' });
|
||||
}
|
||||
if (page == 1) {
|
||||
this.setData({ list,page });
|
||||
} else {
|
||||
const list2 = this.data.list.concat(list);
|
||||
this.setData({ list: list2 ,page});
|
||||
}
|
||||
});
|
||||
},
|
||||
loadMore() {
|
||||
const { page, listEndText } = this.data;
|
||||
if (listEndText == '点击加载更多。。。') {
|
||||
this.fetchList(page + 1);
|
||||
}
|
||||
},
|
||||
onReachBottom() {
|
||||
this.loadMore();
|
||||
},
|
||||
})
|
||||
12
pages/sharelist/sharelist.json
Normal file
12
pages/sharelist/sharelist.json
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"navigationBarTitleText": "进行中的分销",
|
||||
"backgroundTextStyle": "light",
|
||||
"usingComponents": {
|
||||
"t-tabs": "tdesign-miniprogram/tabs/tabs",
|
||||
"t-tab-panel": "tdesign-miniprogram/tab-panel/tab-panel",
|
||||
"t-image": "tdesign-miniprogram/image/image",
|
||||
"t-sticky": "tdesign-miniprogram/sticky/sticky",
|
||||
"t-divider": "tdesign-miniprogram/divider/divider",
|
||||
"t-footer": "tdesign-miniprogram/footer/footer"
|
||||
}
|
||||
}
|
||||
23
pages/sharelist/sharelist.wxml
Normal file
23
pages/sharelist/sharelist.wxml
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<view>
|
||||
<view class="list">
|
||||
<view class="item" wx:for="{{list}}" wx:key="id">
|
||||
<view class="item-main" data-detail="{{item}}" data-index="{{index}}" bind:tap="goDel">
|
||||
<view class="right">
|
||||
<view class="text">
|
||||
<view>{{item.buy_type || '-'}}</view>
|
||||
<view>{{item.price}}元</view>
|
||||
</view>
|
||||
<view class="info">
|
||||
<view></view>
|
||||
<view wx:if="{{item.deleted == 0}}" style="text-align: right;color:coral">置为失效</view>
|
||||
</view>
|
||||
<view class="info">
|
||||
<view>创建: {{item.create_time}}</view>
|
||||
<view>截止: {{item.expire_time}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<t-footer wx:if="{{listEndText}}" text="{{listEndText}}" bind:tap="loadMore"></t-footer>
|
||||
</view>
|
||||
</view>
|
||||
76
pages/sharelist/sharelist.wxss
Normal file
76
pages/sharelist/sharelist.wxss
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
page {
|
||||
padding: 0 20rpx;
|
||||
background-color: rgb(245, 246, 247);
|
||||
}
|
||||
.sw {
|
||||
width: 240rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 32rpx;
|
||||
}
|
||||
|
||||
.sw .txt {
|
||||
padding-left: 16rpx;
|
||||
}
|
||||
|
||||
|
||||
.list {
|
||||
margin-top: 20rpx;
|
||||
padding-bottom: 60rpx;
|
||||
}
|
||||
|
||||
.list .item {
|
||||
border-radius: 16rpx;
|
||||
background-color: #fff;
|
||||
margin-bottom: 20rpx;
|
||||
width: 710rpx;
|
||||
padding-top: 20rpx;
|
||||
}
|
||||
|
||||
.list .item .item-main {
|
||||
display: flex;
|
||||
padding-left: 20rpx;
|
||||
}
|
||||
|
||||
.list .item .item-main .right {
|
||||
flex: 1;
|
||||
padding: 0 32rpx;
|
||||
padding-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.list .item .item-main .right .text {
|
||||
display: flex;
|
||||
font-size: 28rpx;
|
||||
justify-content: space-between;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.list .item .item-main .right .info {
|
||||
display: flex;
|
||||
font-size: 24rpx;
|
||||
justify-content: space-between;
|
||||
color: #8f9197;
|
||||
line-height: 36rpx;
|
||||
}
|
||||
|
||||
.list .item .item-main .right .info .viewcnt {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 20rpx;
|
||||
}
|
||||
|
||||
.list .item .item-main .right .info .viewcnt.init {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
.list .item .item-main .right .info .viewcnt.resolve {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.list .item .item-main .right .info .viewcnt.reject {
|
||||
color: gray;
|
||||
}
|
||||
|
||||
.list .item .h20 {
|
||||
height: 20rpx;
|
||||
}
|
||||
66
pages/shop/shop.js
Normal file
66
pages/shop/shop.js
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
// pages/shop/shop.js
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
}
|
||||
})
|
||||
2
pages/shop/shop.wxml
Normal file
2
pages/shop/shop.wxml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!--pages/shop/shop.wxml-->
|
||||
<text>pages/shop/shop.wxml</text>
|
||||
405
pages/takephoto/takephoto.js
Normal file
405
pages/takephoto/takephoto.js
Normal file
|
|
@ -0,0 +1,405 @@
|
|||
import R from '../../utils/request';
|
||||
import C from '../../utils/constant';
|
||||
Page({
|
||||
data: {
|
||||
cdnHost: C.cdnHost,
|
||||
cdnHost: C.cdnHost,
|
||||
title: '',
|
||||
tel: '',
|
||||
content: '',
|
||||
shortAddress: '',
|
||||
address: '',
|
||||
video: '',
|
||||
position: {
|
||||
longitude: 0,
|
||||
latitude: 0,
|
||||
},
|
||||
ds: {
|
||||
list: [],
|
||||
refStatusNum: { finished: 0, failed: 0, process: 0 },
|
||||
},
|
||||
ts: {
|
||||
refImgDescs: {},
|
||||
refImgKeywords: {},
|
||||
fileUploadList: [],
|
||||
fileUploadList2: [],
|
||||
isUploading: false,
|
||||
timer: [],
|
||||
},
|
||||
stop: false,
|
||||
gridConfig: {
|
||||
column: 4,
|
||||
width: 160,
|
||||
height: 160,
|
||||
},
|
||||
config: {
|
||||
count: 1,
|
||||
},
|
||||
phoneError: false,
|
||||
//
|
||||
videoFileList: [],
|
||||
},
|
||||
onLoad(options) {
|
||||
const that = this;
|
||||
R.get('/index.php/api/v1/my', {}).then(({ model }) => {
|
||||
this.setData({ tel: model.phone });
|
||||
});
|
||||
wx.getFuzzyLocation({
|
||||
type: 'wgs84',
|
||||
success(res) {
|
||||
const longitude = res.longitude
|
||||
const latitude = res.latitude
|
||||
that.setData({
|
||||
position: {
|
||||
longitude,
|
||||
latitude,
|
||||
},
|
||||
});
|
||||
R.get('/index.php/api/v1/gps', { lat: latitude, lon: longitude }).then(({ model }) => {
|
||||
that.setData({ shortAddress: model.short_ad, address: model.full_ad });
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
onUnload() {
|
||||
this.data.stop = true;
|
||||
},
|
||||
onShareAppMessage() {
|
||||
},
|
||||
choosePoi() {
|
||||
const that = this;
|
||||
wx.chooseLocation({
|
||||
success({ latitude, longitude, name, address }) {
|
||||
that.setData({
|
||||
position: {
|
||||
latitude,
|
||||
longitude,
|
||||
},
|
||||
shortAddress: name,
|
||||
address,
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
//
|
||||
onPhoneInput(e) {
|
||||
const { phoneError } = this.data;
|
||||
const isPhoneNumber = /^[1][3,4,5,7,8,9][0-9]{9}$/.test(e.detail.value);
|
||||
if (phoneError === isPhoneNumber) {
|
||||
this.setData({
|
||||
phoneError: !isPhoneNumber,
|
||||
});
|
||||
}
|
||||
},
|
||||
onSubmit() {
|
||||
console.log('this.stat', this.data);
|
||||
const { title, tel, shortAddress, address, position, ds, content, videoFileList } = this.data;
|
||||
if (ds.refStatusNum.failed > 0) {
|
||||
wx.showToast({
|
||||
title: '请处理上传失败的图片',
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (ds.refStatusNum.process > 0) {
|
||||
wx.showToast({
|
||||
title: '请等待图片上传完成',
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 每个属性都判空,并且给出toast提示
|
||||
if (!tel) {
|
||||
wx.showToast({
|
||||
title: '请输入手机号',
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!title) {
|
||||
wx.showToast({
|
||||
title: '请输入标题',
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!content) {
|
||||
wx.showToast({
|
||||
title: '请输入您的发件信息',
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!shortAddress) {
|
||||
wx.showToast({
|
||||
title: '请选择位置',
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (ds.list.length === 0) {
|
||||
wx.showToast({
|
||||
title: '请上传图片',
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 提交数据
|
||||
R.post('/index.php/api/v1/submit', {
|
||||
title,
|
||||
tel,
|
||||
shortAddress,
|
||||
address,
|
||||
content,
|
||||
longitude: position.longitude,
|
||||
latitude: position.latitude,
|
||||
imgs: ds.list.map((o) => o.path),
|
||||
video: videoFileList && videoFileList.length > 0 ? videoFileList[0].path : undefined,
|
||||
}).then(({ model }) => {
|
||||
wx.showToast({
|
||||
title: '提交成功,感谢您的反馈',
|
||||
icon: 'success',
|
||||
});
|
||||
setTimeout(() => {
|
||||
wx.navigateBack();
|
||||
}, 1000);
|
||||
});
|
||||
},
|
||||
goBack() {
|
||||
wx.navigateBack();
|
||||
},
|
||||
//
|
||||
callStatusNum() {
|
||||
const { ds } = this.data;
|
||||
const s = { finished: 0, failed: 0, process: 0 };
|
||||
ds.list.forEach((o) => {
|
||||
if (o.failed) s.failed++;
|
||||
else if (o.finished) s.finished++;
|
||||
else s.process++;
|
||||
});
|
||||
this.setData({
|
||||
'ds.refStatusNum': s,
|
||||
});
|
||||
},
|
||||
imgHandleSuccess(e) {
|
||||
console.log('imgHandleSuccess', e.detail);
|
||||
// const { files } = e.detail;
|
||||
// this.setData({
|
||||
// originFiles: files,
|
||||
// });
|
||||
this.httpRequest();
|
||||
},
|
||||
imgHandleRemove(e) {
|
||||
const { index } = e.detail;
|
||||
console.log('imgHandleRemove', e.detail);
|
||||
const { ds } = this.data;
|
||||
ds.list.splice(index, 1);
|
||||
this.setData({
|
||||
'ds.list': ds.list,
|
||||
});
|
||||
},
|
||||
imgHandleClick(e) {
|
||||
console.log(e.detail.file);
|
||||
},
|
||||
beforUpload(e) {
|
||||
const { files } = e.detail;
|
||||
console.log('beforUpload', files);
|
||||
const { ts } = this.data;
|
||||
const { fileUploadList, fileUploadList2 } = ts;
|
||||
files.map((file) => {
|
||||
fileUploadList.push(file);
|
||||
fileUploadList2.push(file);
|
||||
})
|
||||
this.setData({
|
||||
'ts.fileUploadList': fileUploadList,
|
||||
'ts.fileUploadList2': fileUploadList2,
|
||||
});
|
||||
},
|
||||
startPreview() {
|
||||
console.log('startPreview');
|
||||
if (this.data.stop) return;
|
||||
const { ts, ds } = this.data;
|
||||
const { fileUploadList2 } = ts;
|
||||
if (fileUploadList2.length > 0) {
|
||||
const file = fileUploadList2.shift();
|
||||
ds.list.push({
|
||||
src: file.url,
|
||||
url: file.url,
|
||||
uid: file.name,
|
||||
name: file.name,
|
||||
percent: 0,
|
||||
failed: false,
|
||||
status: 'loading',
|
||||
})
|
||||
this.setData({
|
||||
'ts.fileUploadList2': fileUploadList2,
|
||||
'ds.list': ds.list,
|
||||
});
|
||||
setTimeout(() => {
|
||||
this.startPreview();
|
||||
}, 0);
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
this.startPreview();
|
||||
}, 2000);
|
||||
}
|
||||
},
|
||||
httpRequest(e) {
|
||||
if (this.data.stop) return;
|
||||
const { ts } = this.data;
|
||||
if (ts.isUploading) return;
|
||||
ts.isUploading = true;
|
||||
console.log('httpRequest');
|
||||
// 循环检测 是否有文件可以上传
|
||||
setTimeout(() => {
|
||||
this.uploadHandle();
|
||||
this.startPreview();
|
||||
}, 0);
|
||||
},
|
||||
uploadHandle() {
|
||||
console.log('uploadHandle');
|
||||
if (this.data.stop) return;
|
||||
this.callStatusNum();
|
||||
const { ts, ds } = this.data;
|
||||
const { fileUploadList } = ts;
|
||||
if (fileUploadList.length > 0) {
|
||||
console.log('fileUploadList', fileUploadList);
|
||||
const file = fileUploadList.shift();
|
||||
// formData.append('imageData', file);
|
||||
R.upload({ a: 1 }, 'img_file', file.url).catch((e) => e).then((response) => {
|
||||
// console.log('response-response333', response);
|
||||
ts.isUploading = false;
|
||||
try {
|
||||
response.data = JSON.parse(response.data);
|
||||
} catch (error) {
|
||||
response.data = null;
|
||||
}
|
||||
// console.log('asdfasd-response', response.data);
|
||||
if (response.data && response.data.code == -1000) {
|
||||
wx.showToast({
|
||||
title: '登录超时,请重新登录',
|
||||
icon: 'none',
|
||||
});
|
||||
setTimeout(() => {
|
||||
wx.navigateTo({ url: '/pages/home/home' });
|
||||
}, 500)
|
||||
return;
|
||||
}
|
||||
else if (response.data && response.data.success) {
|
||||
console.log('asdfasd-response2222', response.data);
|
||||
const { data: { model: { path } } } = response;
|
||||
this.setData({
|
||||
'ds.list': ds.list.map((o) => {
|
||||
if (file.name == o.uid) {
|
||||
return { ...o, path, finished: true, percent: 100, status: 'done' };
|
||||
}
|
||||
return { ...o };
|
||||
})
|
||||
});
|
||||
// this.setData({
|
||||
// [`ds.list[${idx}].url`]: C.cdnHost + path,
|
||||
// });
|
||||
// R.getImg(4, imageId).then((path) => {
|
||||
// const tlist = this.data.ds.list;
|
||||
// let idx = 0;
|
||||
// // console.log('path', path);
|
||||
// tlist.forEach((c, i) => {
|
||||
// if (c.imageId == imageId) {
|
||||
// idx = i;
|
||||
// }
|
||||
// });
|
||||
// if (idx) {
|
||||
// this.setData({
|
||||
// [`ds.list[${idx}].url`]: path,
|
||||
// });
|
||||
// }
|
||||
// })
|
||||
// wx.showToast({
|
||||
// title: '图片:' + file.name + '已暂存',
|
||||
// icon: 'success',
|
||||
// });
|
||||
// this.saveTmpData();
|
||||
} else {
|
||||
console.log(response, file.name);
|
||||
let errorMsg = '上传失败,请移除后重试';
|
||||
// if (response.data && response.data.status == 529) {
|
||||
// errorMsg = '其他图集中已存在,请移除';
|
||||
// }
|
||||
this.setData({
|
||||
'ds.list': ds.list.map((o) => {
|
||||
if (file.name == o.uid) {
|
||||
return { ...o, failed: errorMsg, status: 'failed' };
|
||||
}
|
||||
return { ...o };
|
||||
}),
|
||||
});
|
||||
wx.showToast({
|
||||
title: file.name + ',' + errorMsg,
|
||||
icon: 'error',
|
||||
});
|
||||
// this.saveTmpData();
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.uploadHandle();
|
||||
}, 0);
|
||||
});
|
||||
} else {
|
||||
// setTimeout(() => {
|
||||
// this.uploadHandle();
|
||||
// }, 2000);
|
||||
}
|
||||
},
|
||||
//video
|
||||
handleVideoAdd(e) {
|
||||
const { files } = e.detail;
|
||||
files.forEach(file => this.uploadVideoFile(file))
|
||||
},
|
||||
uploadVideoFile(file) {
|
||||
|
||||
wx.getVideoInfo({ src: file.url }).then((res) => {
|
||||
if (res.duration > 180) {
|
||||
wx.showToast({
|
||||
title: '视频时长不能超过3分钟',
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
const { videoFileList } = this.data;
|
||||
|
||||
this.setData({
|
||||
videoFileList: [...videoFileList, { ...file, path: '', status: 'loading' }],
|
||||
});
|
||||
const { length } = videoFileList;
|
||||
R.upload({ a: 2 }, 'video_file', file.url, (res) => {
|
||||
this.setData({
|
||||
[`videoFileList[${length}].percent`]: res.progress,
|
||||
});
|
||||
}).catch((e) => e).then((response) => {
|
||||
try {
|
||||
response.data = JSON.parse(response.data);
|
||||
} catch (error) {
|
||||
response.data = null;
|
||||
}
|
||||
if (response.data && response.data.success) {
|
||||
const { data: { model: { path } } } = response;
|
||||
console.log('asdfasd-response2222', response.data, this.data.videoFileList, length);
|
||||
this.setData({
|
||||
[`videoFileList[${length}].status`]: 'done',
|
||||
[`videoFileList[${length}].path`]: path,
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
handleVideoRemove(e) {
|
||||
const { index } = e.detail;
|
||||
const { videoFileList } = this.data;
|
||||
|
||||
videoFileList.splice(index, 1);
|
||||
this.setData({
|
||||
videoFileList,
|
||||
});
|
||||
},
|
||||
})
|
||||
14
pages/takephoto/takephoto.json
Normal file
14
pages/takephoto/takephoto.json
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"navigationBarTitleText": "有发现",
|
||||
"backgroundTextStyle": "light",
|
||||
"usingComponents": {
|
||||
"t-image": "tdesign-miniprogram/image/image",
|
||||
"t-input": "tdesign-miniprogram/input/input",
|
||||
"t-cell": "tdesign-miniprogram/cell/cell",
|
||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||
"t-notice-bar": "tdesign-miniprogram/notice-bar/notice-bar",
|
||||
"t-upload": "tdesign-miniprogram/upload/upload",
|
||||
"t-button": "tdesign-miniprogram/button/button",
|
||||
"t-textarea": "tdesign-miniprogram/textarea/textarea"
|
||||
}
|
||||
}
|
||||
35
pages/takephoto/takephoto.wxml
Normal file
35
pages/takephoto/takephoto.wxml
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<view>
|
||||
<image class="img" src="{{cdnHost + '/static/bg_take.jpeg?v=5'}}" />
|
||||
<!-- <view class="img"> -->
|
||||
<!-- <view>发布信息审核通过后获10元红包</view> -->
|
||||
<!-- </view> -->
|
||||
<view class="form">
|
||||
<t-input label="标题" placeholder="请输入您的发现标题" model:value="{{title}}" align="right" />
|
||||
<t-input label="手机" type="number" tips="{{phoneError ? '手机号输入不正确' : ''}}" bindchange="onPhoneInput" placeholder="请输入您的手机号码" model:value="{{tel}}" align="right" />
|
||||
<t-cell title="现场图片" description="最多6张图片" hover></t-cell>
|
||||
<t-cell class="photos">
|
||||
<view class="wrapper" slot="description">
|
||||
<t-upload max="{{6}}" size-limit="{{102400}}" media-type="{{['image']}}" files="{{ds.list}}" gridConfig="{{gridConfig}}" bind:success="imgHandleSuccess" bind:remove="imgHandleRemove" bind:click="imgHandleClick" request-method="{{httpRequest}}" bind:add="beforUpload" />
|
||||
</view>
|
||||
</t-cell>
|
||||
<t-cell title="现场视频(可选)" description="最多一个视频(3分钟内)" hover>
|
||||
<t-upload slot="note" mediaType="{{['video']}}" max="{{1}}" files="{{videoFileList}}" bind:add="handleVideoAdd" bind:remove="handleVideoRemove"></t-upload>
|
||||
</t-cell>
|
||||
<t-textarea t-class="external-class" label="" placeholder="请输入具体内容" value="" maxcharacter="5000" disableDefaultPadding="{{true}}" model:value="{{content}}" />
|
||||
<view class="local_bar">
|
||||
<view class="local">
|
||||
<t-icon name="location-1" size="30rpx" color="green"></t-icon>
|
||||
{{shortAddress}}
|
||||
</view>
|
||||
<view class="btn" bind:tap="choosePoi">
|
||||
修正位置
|
||||
<t-icon name="chevron-right" size="28rpx"></t-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<t-notice-bar visible="{{true}}" theme="warning" content="请确保您发布的信息真实有效"></t-notice-bar>
|
||||
<view class="btns">
|
||||
<t-button theme="primary" size="large" block bind:tap="onSubmit">确认发布</t-button>
|
||||
<t-button theme="primary" size="large" block variant="outline" bind:tap="goBack">取消</t-button>
|
||||
</view>
|
||||
</view>
|
||||
93
pages/takephoto/takephoto.wxss
Normal file
93
pages/takephoto/takephoto.wxss
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
page {
|
||||
background-color: rgb(245, 246, 247);
|
||||
}
|
||||
|
||||
.img {
|
||||
font-size: 12rpx;
|
||||
width: 750rpx;
|
||||
margin: 0 auto;
|
||||
height: 530rpx;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.form {
|
||||
margin: 0 20rpx;
|
||||
border-radius: 4px;
|
||||
background-color: #fff;
|
||||
margin-top: -100rpx;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.form .t-input__label {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.form .t-input__label::after {
|
||||
display: block;
|
||||
content: '*';
|
||||
color: #f00;
|
||||
position: absolute;
|
||||
font-size: 40rpx;
|
||||
right: -30rpx;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.form .photos .t-image {
|
||||
margin-left: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.t-textarea__wrapper {
|
||||
background-color: rgb(245, 246, 247);
|
||||
border: 16rpx;
|
||||
}
|
||||
|
||||
.t-textarea__wrapper .t-textarea__wrapper-inner {
|
||||
padding: 16rpx;
|
||||
border: 16rpx;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.local_bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0 40rpx;
|
||||
border-bottom: 10px solid #fff;
|
||||
}
|
||||
|
||||
.local_bar .t-icon {
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
|
||||
.local_bar .local {
|
||||
display: flex;
|
||||
font-size: 24rpx;
|
||||
align-items: center;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.local_bar .btn {
|
||||
display: flex;
|
||||
font-size: 24rpx;
|
||||
align-items: center;
|
||||
color: blue;
|
||||
}
|
||||
|
||||
.t-notice-bar {
|
||||
background: none !important;
|
||||
}
|
||||
|
||||
.btns {
|
||||
padding: 0 40rpx;
|
||||
padding-bottom: 90rpx;
|
||||
}
|
||||
|
||||
.btns .t-button {
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.t-upload .t-grid__content .t-grid-item {
|
||||
width: auto !important;
|
||||
}
|
||||
66
pages/test/test.js
Normal file
66
pages/test/test.js
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
// pages/test/test.js
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
}
|
||||
})
|
||||
2
pages/test/test.wxml
Normal file
2
pages/test/test.wxml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!--pages/test/test.wxml-->
|
||||
<text>pages/test/test.wxml</text>
|
||||
35
pages/usercenter/components/user-center-card/index.js
Normal file
35
pages/usercenter/components/user-center-card/index.js
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
const AuthStepType = {
|
||||
ONE: 1,
|
||||
TWO: 2,
|
||||
THREE: 3,
|
||||
};
|
||||
|
||||
Component({
|
||||
options: {
|
||||
multipleSlots: true,
|
||||
},
|
||||
properties: {
|
||||
currAuthStep: {
|
||||
type: Number,
|
||||
value: AuthStepType.ONE,
|
||||
},
|
||||
userInfo: {
|
||||
type: Object,
|
||||
value: {},
|
||||
},
|
||||
isNeedGetUserInfo: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
},
|
||||
data: {
|
||||
defaultAvatarUrl:
|
||||
'https://cdn-we-retail.ym.tencent.com/miniapp/usercenter/icon-user-center-avatar@2x.png',
|
||||
AuthStepType,
|
||||
},
|
||||
methods: {
|
||||
gotoUserEditPage() {
|
||||
this.triggerEvent('gotoUserEditPage');
|
||||
},
|
||||
},
|
||||
});
|
||||
7
pages/usercenter/components/user-center-card/index.json
Normal file
7
pages/usercenter/components/user-center-card/index.json
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||
"t-avatar": "tdesign-miniprogram/avatar/avatar"
|
||||
}
|
||||
}
|
||||
36
pages/usercenter/components/user-center-card/index.wxml
Normal file
36
pages/usercenter/components/user-center-card/index.wxml
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<view class="user-center-card">
|
||||
<!-- 未登录的情况 -->
|
||||
<block wx:if="{{currAuthStep === AuthStepType.ONE}}">
|
||||
<view class="user-center-card__header" bind:tap="gotoUserEditPage">
|
||||
<t-avatar image="{{userInfo.avatarUrl || defaultAvatarUrl}}" class="user-center-card__header__avatar" />
|
||||
<view class="user-center-card__header__name">{{'请登录'}}</view>
|
||||
</view>
|
||||
</block>
|
||||
<!-- 已登录但未授权用户信息情况 -->
|
||||
<block wx:if="{{currAuthStep === AuthStepType.TWO}}">
|
||||
<view class="user-center-card__header">
|
||||
<t-avatar image="{{userInfo.avatarUrl || defaultAvatarUrl}}" class="user-center-card__header__avatar" />
|
||||
<view class="user-center-card__header__name">
|
||||
<view class="name">{{userInfo.nickName || '微信用户'}}</view>
|
||||
</view>
|
||||
<!-- 需要授权用户信息,通过slot添加弹窗 -->
|
||||
<view class="user-center-card__header__transparent" wx:if="{{isNeedGetUserInfo}}">
|
||||
<slot name="getUserInfo" />
|
||||
</view>
|
||||
<!-- 不需要授权用户信息,仍然触发gotoUserEditPage事件 -->
|
||||
<view class="user-center-card__header__transparent" bind:tap="gotoUserEditPage" wx:else></view>
|
||||
</view>
|
||||
</block>
|
||||
<!-- 已登录且已经授权用户信息的情况 -->
|
||||
<block wx:if="{{currAuthStep === AuthStepType.THREE}}">
|
||||
<view class="user-center-card__header" bind:tap="gotoUserEditPage">
|
||||
<t-avatar
|
||||
t-class="avatar"
|
||||
mode="aspectFill"
|
||||
class="user-center-card__header__avatar"
|
||||
image="{{userInfo.avatarUrl || defaultAvatarUrl}}"
|
||||
/>
|
||||
<view class="user-center-card__header__name">{{userInfo.nickName || '微信用户'}}</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
57
pages/usercenter/components/user-center-card/index.wxss
Normal file
57
pages/usercenter/components/user-center-card/index.wxss
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
.user-center-card {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 480rpx;
|
||||
background-image: url('https://cdn-we-retail.ym.tencent.com/miniapp/template/user-center-bg-v1.png');
|
||||
background-size: cover;
|
||||
background-repeat: no-repeat;
|
||||
padding: 0 24rpx;
|
||||
}
|
||||
.user-center-card__header {
|
||||
margin-top: 192rpx;
|
||||
margin-bottom: 48rpx;
|
||||
height: 96rpx;
|
||||
line-height: 48rpx;
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
color: #333;
|
||||
position: relative;
|
||||
}
|
||||
.user-center-card__header__avatar {
|
||||
width: 96rpx;
|
||||
height: 96rpx;
|
||||
border-radius: 48rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.user-center-card__header__name .name{
|
||||
font-size: 36rpx;
|
||||
line-height: 48rpx;
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
margin-left: 24rpx;
|
||||
margin-right: 16rpx;
|
||||
}
|
||||
.user-center-card__header__name .score{
|
||||
font-size: 22rpx;
|
||||
line-height: 38rpx;
|
||||
color: #333;
|
||||
margin-left: 24rpx;
|
||||
margin-right: 16rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.user-center-card__header__transparent {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
background-color: transparent;
|
||||
height: 100%;
|
||||
width: 30%;
|
||||
}
|
||||
.user-center-card__icon {
|
||||
line-height: 96rpx;
|
||||
}
|
||||
79
pages/usercenter/index.js
Normal file
79
pages/usercenter/index.js
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
import R from '../../utils/request';
|
||||
import C from '../../utils/constant';
|
||||
import * as F from '../../utils/func';
|
||||
|
||||
Page({
|
||||
data: {
|
||||
cdnHost: C.cdnHost,
|
||||
phone: '',
|
||||
name: '',
|
||||
price_sum: '',
|
||||
share_cnt: '',
|
||||
share_view_cnt: '',
|
||||
is_share: false,
|
||||
show_vip_link: false,
|
||||
payed_vip_link: '',
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.getTabBar().init();
|
||||
this.init();
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
this.init();
|
||||
},
|
||||
|
||||
init() {
|
||||
this.fetUserInfoHandle();
|
||||
},
|
||||
|
||||
fetUserInfoHandle() {
|
||||
R.get('/index.php/api/v1/my').then(({ model }) => {
|
||||
this.setData({
|
||||
name: model.real_name || model.nick_name || '微信用户',
|
||||
phone: model.phone || '-',
|
||||
share_cnt: model.share_cnt,
|
||||
share_view_cnt: model.share_view_cnt,
|
||||
price_sum: F.formatePrice(model.price_sum || 0),
|
||||
is_share: !!model.is_share,
|
||||
show_vip_link: model.show_vip_link || false,
|
||||
payed_vip_link: model.payed_vip_link || '',
|
||||
});
|
||||
})
|
||||
},
|
||||
getPhoneNumber(e) {
|
||||
console.log(e.detail.code) // 动态令牌
|
||||
console.log(e.detail.errMsg) // 回调信息(成功失败都会返回)
|
||||
console.log(e.detail.errno) // 错误码(失败时返回)
|
||||
if (!e.detail.errno) {
|
||||
R.post('/index.php/api/v1/bind_auth_phone', { code: e.detail.code }).then(() => {
|
||||
this.setData({ hasPhone: true })
|
||||
this.goH5Shop();
|
||||
})
|
||||
} else {
|
||||
// e.detail.errMsg
|
||||
}
|
||||
},
|
||||
goShared() {
|
||||
wx.switchTab({
|
||||
url: '/pages/faxianlist/faxianlist',
|
||||
})
|
||||
},
|
||||
goOrder() {
|
||||
wx.navigateTo({ url: '/pages/paylist/paylist' })
|
||||
},
|
||||
toVipLink() {
|
||||
wx.navigateTo({ url: '/pages/webview/webview?url='+encodeURIComponent(this.data.payed_vip_link) })
|
||||
},
|
||||
goSharelist() {
|
||||
wx.navigateTo({ url: '/pages/sharelist/sharelist' })
|
||||
},
|
||||
goInfo() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/usercenter/info',
|
||||
})
|
||||
},
|
||||
});
|
||||
9
pages/usercenter/index.json
Normal file
9
pages/usercenter/index.json
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"navigationBarTitleText": "个人中心",
|
||||
"usingComponents": {
|
||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||
"t-link": "tdesign-miniprogram/link/link",
|
||||
"t-cell": "tdesign-miniprogram/cell/cell"
|
||||
},
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
173
pages/usercenter/index.less
Normal file
173
pages/usercenter/index.less
Normal file
|
|
@ -0,0 +1,173 @@
|
|||
page {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.header {
|
||||
background-color: linear-gradient(180deg, #f0f4fc, #fff);
|
||||
position: relative;
|
||||
|
||||
background-color: rgba(255, 255, 255, 0.8);
|
||||
box-sizing: border-box;
|
||||
width: 90%;
|
||||
margin: 0 auto;
|
||||
margin-top: -300rpx;
|
||||
border-radius: 10rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.header .info {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.header .info::after {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.header .avatar {
|
||||
width: 96rpx;
|
||||
height: 96rpx;
|
||||
border-radius: 50%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.cb {
|
||||
top: 10rpx;
|
||||
right: 100rpx;
|
||||
height: 530rpx;
|
||||
width: 750rpx;
|
||||
background: url('http://cdn.zhonganonline.top/newslist/static/bg_take.jpeg?v=5') no-repeat;
|
||||
background-position: center center;
|
||||
background-size: 100% 100%;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.vip {
|
||||
background: linear-gradient(90deg, #f9e9bc, #f2d786);
|
||||
border-radius: 20rpx;
|
||||
height: 154rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0 40rpx;
|
||||
width: 94%;
|
||||
margin: 0 auto;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.vip .dest .a {
|
||||
color: #775d2f;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
|
||||
.vip .dest .b {
|
||||
color: #775d2f;
|
||||
opacity: 0.8;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.vip .btn {
|
||||
background-color: #fff;
|
||||
color: #775d2f;
|
||||
font-size: 24rpx;
|
||||
height: 68rpx;
|
||||
width: 164rpx;
|
||||
border-radius: 34rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.title_bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: 32rpx;
|
||||
width: 92%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.title_bar .title {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
||||
background-position: left center;
|
||||
background-size: 100% 100%;
|
||||
font-size: 32rpx;
|
||||
color: rgb(53, 58, 71);
|
||||
height: 34rpx;
|
||||
width: 132rpx;
|
||||
}
|
||||
|
||||
.title_bar .btn {
|
||||
color: #f09759;
|
||||
font-size: 28rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background-color: #fff8e9;
|
||||
padding: 10rpx 20rpx;
|
||||
border-radius: 6rpx;
|
||||
}
|
||||
|
||||
.title_bar .btn .t-icon {
|
||||
margin-right: 4rpx;
|
||||
}
|
||||
|
||||
.ma20 {
|
||||
height: 20rpx;
|
||||
background-color: #f5f5f5;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.cards_w {
|
||||
background-color: #fff;
|
||||
width: 94%;
|
||||
border-radius: 6rpx;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.cards_w .cards {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 30rpx 0;
|
||||
}
|
||||
|
||||
.cards_w .cards .card {
|
||||
width: 28%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: none;
|
||||
font-size: 0;
|
||||
line-height: 24rpx;
|
||||
|
||||
&::after {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.cards_w .cards .card .txt {
|
||||
padding-top: 12rpx;
|
||||
font-size: 24rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.cards_w .cards .card .txt2 {
|
||||
padding-top: 12rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.cards_w .cards .card.hide {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.link {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 30rpx 0;
|
||||
width: 50%;
|
||||
margin: 0 auto;
|
||||
background-color: #fff;
|
||||
border-radius: 6rpx;
|
||||
}
|
||||
49
pages/usercenter/index.wxml
Normal file
49
pages/usercenter/index.wxml
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<view class="cb"></view>
|
||||
<view class="header">
|
||||
<t-cell class="info" title="{{name}}" image="{{cdnHost + '/static/header.png?v=5'}}" description="{{phone}}" hover arrow bind:tap="goInfo"></t-cell>
|
||||
</view>
|
||||
<!-- <view class="vip">
|
||||
<view class="dest">
|
||||
<view class="a">美丽桐庐监督行动</view>
|
||||
<view class="b" wx:if="{{price * 1}}">经审核后可获得{{price}}元现金奖励</view>
|
||||
</view>
|
||||
<view class="btn" bind:tap="goTakePhoto">参与试试</view>
|
||||
</view> -->
|
||||
<!-- <view class="ma20"></view> -->
|
||||
<!-- <view class="title_bar"> -->
|
||||
<!-- <view class="title">服务数据</view> -->
|
||||
<!-- <view class="btn" bind:tap="goTakePhoto">
|
||||
<t-icon name="camera" size="28rpx" color="f09759"></t-icon>
|
||||
有发现
|
||||
</view> -->
|
||||
<!-- </view> -->
|
||||
<!-- <view class="ma20"></view> -->
|
||||
<view class="cards_w">
|
||||
<view class="cards" wx:if="{{is_share}}">
|
||||
<view class="card" bind:tap="goShared">
|
||||
<view class="txt2">{{price_sum}}元</view>
|
||||
<view class="txt">总收入</view>
|
||||
</view>
|
||||
<!-- aa -->
|
||||
<view class="card" bind:tap="goSharelist">
|
||||
<view class="txt2">{{share_cnt}}次</view>
|
||||
<view class="txt">总分享</view>
|
||||
</view>
|
||||
<view class="card">
|
||||
<view class="txt2">{{share_view_cnt}}</view>
|
||||
<view class="txt">分享浏览</view>
|
||||
</view>
|
||||
<!-- /aa -->
|
||||
<!-- <view class="card hide">
|
||||
<t-icon name="location" size="30" color="#aaa" />
|
||||
<view class="txt">---</view>
|
||||
</view> -->
|
||||
</view>
|
||||
<view class="ma20"></view>
|
||||
<t-cell class="info" title="我的订单" hover arrow bind:tap="goOrder"></t-cell>
|
||||
<view class="ma20"></view>
|
||||
<view class="ma20"></view>
|
||||
<view class="link" wx:if="{{show_vip_link}}">
|
||||
<t-link size="small" theme="primary" content="专属服务企业、微信群" suffixIcon="jump" hover bind:tap="toVipLink" />
|
||||
</view>
|
||||
</view>
|
||||
150
pages/usercenter/index.wxss
Normal file
150
pages/usercenter/index.wxss
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
page {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
.header {
|
||||
background-color: linear-gradient(180deg, #f0f4fc, #fff);
|
||||
position: relative;
|
||||
background-color: rgba(255, 255, 255, 0.8);
|
||||
box-sizing: border-box;
|
||||
width: 90%;
|
||||
margin: 0 auto;
|
||||
margin-top: -300rpx;
|
||||
border-radius: 10rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
.header .info {
|
||||
background-color: transparent;
|
||||
}
|
||||
.header .info::after {
|
||||
display: none;
|
||||
}
|
||||
.header .avatar {
|
||||
width: 96rpx;
|
||||
height: 96rpx;
|
||||
border-radius: 50%;
|
||||
overflow: hidden;
|
||||
}
|
||||
.cb {
|
||||
top: 10rpx;
|
||||
right: 100rpx;
|
||||
height: 530rpx;
|
||||
width: 750rpx;
|
||||
background: url('http://cdn.zhonganonline.top/newslist/static/bg_take.jpeg?v=5') no-repeat;
|
||||
background-position: center center;
|
||||
background-size: 100% 100%;
|
||||
z-index: 1;
|
||||
}
|
||||
.vip {
|
||||
background: linear-gradient(90deg, #f9e9bc, #f2d786);
|
||||
border-radius: 20rpx;
|
||||
height: 154rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0 40rpx;
|
||||
width: 94%;
|
||||
margin: 0 auto;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.vip .dest .a {
|
||||
color: #775d2f;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
.vip .dest .b {
|
||||
color: #775d2f;
|
||||
opacity: 0.8;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
.vip .btn {
|
||||
background-color: #fff;
|
||||
color: #775d2f;
|
||||
font-size: 24rpx;
|
||||
height: 68rpx;
|
||||
width: 164rpx;
|
||||
border-radius: 34rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.title_bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: 32rpx;
|
||||
width: 92%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.title_bar .title {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
||||
background-position: left center;
|
||||
background-size: 100% 100%;
|
||||
font-size: 32rpx;
|
||||
color: #353a47;
|
||||
height: 34rpx;
|
||||
width: 132rpx;
|
||||
}
|
||||
.title_bar .btn {
|
||||
color: #f09759;
|
||||
font-size: 28rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background-color: #fff8e9;
|
||||
padding: 10rpx 20rpx;
|
||||
border-radius: 6rpx;
|
||||
}
|
||||
.title_bar .btn .t-icon {
|
||||
margin-right: 4rpx;
|
||||
}
|
||||
.ma20 {
|
||||
height: 20rpx;
|
||||
background-color: #f5f5f5;
|
||||
width: 100%;
|
||||
}
|
||||
.cards_w {
|
||||
background-color: #fff;
|
||||
width: 94%;
|
||||
border-radius: 6rpx;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.cards_w .cards {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 30rpx 0;
|
||||
}
|
||||
.cards_w .cards .card {
|
||||
width: 28%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: none;
|
||||
font-size: 0;
|
||||
line-height: 24rpx;
|
||||
}
|
||||
.cards_w .cards .card::after {
|
||||
display: none;
|
||||
}
|
||||
.cards_w .cards .card .txt {
|
||||
padding-top: 12rpx;
|
||||
font-size: 24rpx;
|
||||
color: #333;
|
||||
}
|
||||
.cards_w .cards .card .txt2 {
|
||||
padding-top: 12rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
.cards_w .cards .card.hide {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
.link {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 30rpx 0;
|
||||
width: 50%;
|
||||
margin: 0 auto;
|
||||
background-color: #fff;
|
||||
border-radius: 6rpx;
|
||||
}
|
||||
31
pages/usercenter/info.js
Normal file
31
pages/usercenter/info.js
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import R from '../../utils/request';
|
||||
|
||||
|
||||
Page({
|
||||
data: {
|
||||
name: '',
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
},
|
||||
|
||||
onShow() {
|
||||
R.get('/index.php/api/v1/my').then(({ model }) => {
|
||||
this.setData({
|
||||
name: model.real_name || model.nick_name || '微信用户',
|
||||
});
|
||||
})
|
||||
},
|
||||
onSubmit(){
|
||||
if(!this.data.name.trim()){
|
||||
wx.showToast({
|
||||
title: '请填写姓名',
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
}
|
||||
R.post('/index.php/api/v1/set_name',{name:this.data.name.trim()}).then(({ model }) => {
|
||||
wx.navigateBack();
|
||||
})
|
||||
}
|
||||
});
|
||||
8
pages/usercenter/info.json
Normal file
8
pages/usercenter/info.json
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"navigationBarTitleText": "个人信息",
|
||||
"backgroundTextStyle": "light",
|
||||
"usingComponents": {
|
||||
"t-input": "tdesign-miniprogram/input/input",
|
||||
"t-button": "tdesign-miniprogram/button/button"
|
||||
}
|
||||
}
|
||||
8
pages/usercenter/info.wxml
Normal file
8
pages/usercenter/info.wxml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<view>
|
||||
<view class="form">
|
||||
<t-input label="姓名" placeholder="请输入您的姓名" model:value="{{name}}" align="right" />
|
||||
</view>
|
||||
<view class="btns">
|
||||
<t-button theme="primary" size="large" block bind:tap="onSubmit">确认</t-button>
|
||||
</view>
|
||||
</view>
|
||||
7
pages/usercenter/info.wxss
Normal file
7
pages/usercenter/info.wxss
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
page {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
.btns{
|
||||
padding: 20rpx 40rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
13
pages/webview/webview.js
Normal file
13
pages/webview/webview.js
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
Page({
|
||||
data: {
|
||||
url: '',
|
||||
},
|
||||
onLoad(options) {
|
||||
let { url } = options;
|
||||
console.log('url',url);
|
||||
const user_id = wx.getStorageSync('user_id');
|
||||
url = url.replace('${user_id}', user_id);
|
||||
this.setData({ url: decodeURIComponent(url) });
|
||||
},
|
||||
})
|
||||
5
pages/webview/webview.json
Normal file
5
pages/webview/webview.json
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"navigationBarTitleText": " ",
|
||||
"backgroundTextStyle": "light",
|
||||
"usingComponents": {}
|
||||
}
|
||||
1
pages/webview/webview.wxml
Normal file
1
pages/webview/webview.wxml
Normal file
|
|
@ -0,0 +1 @@
|
|||
<web-view wx:if="{{url}}" src="{{url}}"></web-view>
|
||||
1
pages/webview/webview.wxss
Normal file
1
pages/webview/webview.wxss
Normal file
|
|
@ -0,0 +1 @@
|
|||
/* pages/webview/webview.wxss */
|
||||
78
project.config.json
Normal file
78
project.config.json
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
{
|
||||
"description": "项目配置文件,详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
|
||||
"setting": {
|
||||
"urlCheck": true,
|
||||
"es6": true,
|
||||
"enhance": true,
|
||||
"postcss": true,
|
||||
"preloadBackgroundData": false,
|
||||
"minified": true,
|
||||
"newFeature": false,
|
||||
"coverView": true,
|
||||
"nodeModules": true,
|
||||
"autoAudits": false,
|
||||
"showShadowRootInWxmlPanel": true,
|
||||
"scopeDataCheck": false,
|
||||
"uglifyFileName": false,
|
||||
"checkInvalidKey": true,
|
||||
"checkSiteMap": true,
|
||||
"uploadWithSourceMap": true,
|
||||
"compileHotReLoad": false,
|
||||
"lazyloadPlaceholderEnable": false,
|
||||
"useMultiFrameRuntime": true,
|
||||
"ignoreDevUnusedFiles": false,
|
||||
"babelSetting": {
|
||||
"ignore": [],
|
||||
"disablePlugins": [],
|
||||
"outputPath": ""
|
||||
},
|
||||
"enableEngineNative": false,
|
||||
"useIsolateContext": true,
|
||||
"userConfirmedBundleSwitch": false,
|
||||
"packNpmManually": false,
|
||||
"packNpmRelationList": [],
|
||||
"minifyWXSS": true,
|
||||
"disableUseStrict": false,
|
||||
"minifyWXML": true,
|
||||
"showES6CompileOption": false,
|
||||
"useCompilerPlugins": false,
|
||||
"ignoreUploadUnusedFiles": true,
|
||||
"useStaticServer": true,
|
||||
"compileWorklet": false,
|
||||
"localPlugins": false,
|
||||
"condition": false,
|
||||
"swc": false,
|
||||
"disableSWC": true
|
||||
},
|
||||
"compileType": "miniprogram",
|
||||
"simulatorType": "wechat",
|
||||
"simulatorPluginLibVersion": {},
|
||||
"condition": {
|
||||
"miniprogram": {
|
||||
"list": [
|
||||
{
|
||||
"name": "首页入口",
|
||||
"pathName": "pages/home/home",
|
||||
"query": "",
|
||||
"scene": null
|
||||
},
|
||||
{
|
||||
"name": "示例页-个人中心",
|
||||
"pathName": "pages/usercenter/index",
|
||||
"query": "",
|
||||
"scene": null
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"editorSetting": {
|
||||
"tabIndent": "insertSpaces",
|
||||
"tabSize": 2
|
||||
},
|
||||
"packOptions": {
|
||||
"ignore": [],
|
||||
"include": []
|
||||
},
|
||||
"appid": "wx1a5ce23035f68f08",
|
||||
"libVersion": "3.5.8"
|
||||
}
|
||||
7
sitemap.json
Normal file
7
sitemap.json
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
|
||||
"rules": [{
|
||||
"action": "allow",
|
||||
"page": "*"
|
||||
}]
|
||||
}
|
||||
306
style/iconfont.wxss
Normal file
306
style/iconfont.wxss
Normal file
|
|
@ -0,0 +1,306 @@
|
|||
@font-face {
|
||||
font-family: 'wr';
|
||||
src: url('https://cdn3.codesign.qq.com/icons/gqxWyZ1yMJZmVXk/Yyg5Zp2LG8292lK/iconfont.woff?t=cfc62dd36011e60805f5c3ad1a20b642')
|
||||
format('woff2');
|
||||
}
|
||||
|
||||
.wr {
|
||||
font-family: 'wr' !important;
|
||||
font-size: 32rpx;
|
||||
font-style: normal;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
.wr-deliver:before {
|
||||
content: '\e033';
|
||||
}
|
||||
.wr-indent_close:before {
|
||||
content: '\e041';
|
||||
}
|
||||
.wr-edit:before {
|
||||
content: '\e002';
|
||||
}
|
||||
.wr-succeed:before {
|
||||
content: '\e00d';
|
||||
}
|
||||
.wr-goods_return:before {
|
||||
content: '\e03c';
|
||||
}
|
||||
.wr-wallet:before {
|
||||
content: '\e051';
|
||||
}
|
||||
.wr-package:before {
|
||||
content: '\e047';
|
||||
}
|
||||
.wr-comment:before {
|
||||
content: '\e037';
|
||||
}
|
||||
.wr-exchang:before {
|
||||
content: '\e03e';
|
||||
}
|
||||
.wr-credit_card:before {
|
||||
content: '\e035';
|
||||
}
|
||||
.wr-service:before {
|
||||
content: '\e04a';
|
||||
}
|
||||
.wr-shop_bag:before {
|
||||
content: '\e02a';
|
||||
}
|
||||
.wr-goods_refund:before {
|
||||
content: '\e03d';
|
||||
}
|
||||
.wr-check:before {
|
||||
content: '\e053';
|
||||
}
|
||||
.wr-wechat:before {
|
||||
content: '\e065';
|
||||
}
|
||||
.wr-cartAdd:before {
|
||||
content: '\e05d';
|
||||
}
|
||||
.wr-home:before {
|
||||
content: '\e020';
|
||||
}
|
||||
.wr-person:before {
|
||||
content: '\e02c';
|
||||
}
|
||||
.wr-cart:before {
|
||||
content: '\e023';
|
||||
}
|
||||
.wr-location:before {
|
||||
content: '\e016';
|
||||
}
|
||||
.wr-arrow_forward:before {
|
||||
content: '\e012';
|
||||
}
|
||||
.wr-close:before {
|
||||
content: '\e021';
|
||||
}
|
||||
.wr-search:before {
|
||||
content: '\e011';
|
||||
}
|
||||
.wr-clear_filled:before {
|
||||
content: '\e027';
|
||||
}
|
||||
.wr-arrow_drop_up:before {
|
||||
content: '\e071';
|
||||
}
|
||||
.wr-arrow_drop_down:before {
|
||||
content: '\e070';
|
||||
}
|
||||
.wr-filter:before {
|
||||
content: '\e038';
|
||||
}
|
||||
.wr-copy:before {
|
||||
content: '\e001';
|
||||
}
|
||||
.wr-arrow_back:before {
|
||||
content: '\e003';
|
||||
}
|
||||
.wr-add_circle:before {
|
||||
content: '\e004';
|
||||
}
|
||||
.wr-Download:before {
|
||||
content: '\e006';
|
||||
}
|
||||
.wr-map:before {
|
||||
content: '\e007';
|
||||
}
|
||||
.wr-store:before {
|
||||
content: '\e008';
|
||||
}
|
||||
.wr-movie:before {
|
||||
content: '\e00a';
|
||||
}
|
||||
.wr-done:before {
|
||||
content: '\e00b';
|
||||
}
|
||||
.wr-minus:before {
|
||||
content: '\e00c';
|
||||
}
|
||||
.wr-list:before {
|
||||
content: '\e00e';
|
||||
}
|
||||
.wr-expand_less:before {
|
||||
content: '\e00f';
|
||||
}
|
||||
.wr-person_add:before {
|
||||
content: '\e010';
|
||||
}
|
||||
.wr-Photo:before {
|
||||
content: '\e013';
|
||||
}
|
||||
.wr-preview:before {
|
||||
content: '\e014';
|
||||
}
|
||||
.wr-remind:before {
|
||||
content: '\e015';
|
||||
}
|
||||
|
||||
.wr-info:before {
|
||||
content: '\e017';
|
||||
}
|
||||
.wr-expand_less_s:before {
|
||||
content: '\e018';
|
||||
}
|
||||
.wr-arrow_forward_s:before {
|
||||
content: '\e019';
|
||||
}
|
||||
.wr-expand_more_s:before {
|
||||
content: '\e01a';
|
||||
}
|
||||
.wr-share:before {
|
||||
content: '\e01d';
|
||||
}
|
||||
.wr-notify:before {
|
||||
content: '\e01e';
|
||||
}
|
||||
.wr-add:before {
|
||||
content: '\e01f';
|
||||
}
|
||||
.wr-Home:before {
|
||||
content: '\e020';
|
||||
}
|
||||
.wr-delete:before {
|
||||
content: '\e022';
|
||||
}
|
||||
.wr-error:before {
|
||||
content: '\e025';
|
||||
}
|
||||
.wr-sort:before {
|
||||
content: '\e028';
|
||||
}
|
||||
.wr-sort_filled:before {
|
||||
content: '\e029';
|
||||
}
|
||||
.wr-shop_bag_filled:before {
|
||||
content: '\e02b';
|
||||
}
|
||||
|
||||
.wr-person_filled:before {
|
||||
content: '\e02d';
|
||||
}
|
||||
.wr-cart_filled:before {
|
||||
content: '\e02e';
|
||||
}
|
||||
.wr-home_filled:before {
|
||||
content: '\e02f';
|
||||
}
|
||||
.wr-add_outline:before {
|
||||
content: '\e030';
|
||||
}
|
||||
|
||||
.wr-compass:before {
|
||||
content: '\e034';
|
||||
}
|
||||
.wr-goods_exchange:before {
|
||||
content: '\e03a';
|
||||
}
|
||||
.wr-group_buy:before {
|
||||
content: '\e03b';
|
||||
}
|
||||
.wr-group:before {
|
||||
content: '\e03f';
|
||||
}
|
||||
.wr-indent_goods:before {
|
||||
content: '\e040';
|
||||
}
|
||||
.wr-help:before {
|
||||
content: '\e042';
|
||||
}
|
||||
.wr-group_takeout:before {
|
||||
content: '\e043';
|
||||
}
|
||||
.wr-label:before {
|
||||
content: '\e044';
|
||||
}
|
||||
.wr-indent_wating:before {
|
||||
content: '\e045';
|
||||
}
|
||||
.wr-member:before {
|
||||
content: '\e046';
|
||||
}
|
||||
|
||||
.wr-scanning:before {
|
||||
content: '\e04b';
|
||||
}
|
||||
.wr-tv:before {
|
||||
content: '\e04d';
|
||||
}
|
||||
.wr-to_top:before {
|
||||
content: '\e04f';
|
||||
}
|
||||
.wr-visibility_off:before {
|
||||
content: '\e050';
|
||||
}
|
||||
.wr-error-1:before {
|
||||
content: '\e052';
|
||||
}
|
||||
|
||||
.wr-arrow_right:before {
|
||||
content: '\e054';
|
||||
}
|
||||
.wr-arrow_left:before {
|
||||
content: '\e056';
|
||||
}
|
||||
.wr-picture_filled:before {
|
||||
content: '\e057';
|
||||
}
|
||||
.wr-navigation:before {
|
||||
content: '\e058';
|
||||
}
|
||||
.wr-telephone:before {
|
||||
content: '\e059';
|
||||
}
|
||||
.wr-indent_time:before {
|
||||
content: '\e05c';
|
||||
}
|
||||
.wr-cart_add:before {
|
||||
content: '\e05d';
|
||||
}
|
||||
.wr-classify:before {
|
||||
content: '\e060';
|
||||
}
|
||||
.wr-place:before {
|
||||
content: '\e063';
|
||||
}
|
||||
.wr-wechat_pay:before {
|
||||
content: '\e064';
|
||||
}
|
||||
.wr-security:before {
|
||||
content: '\e066';
|
||||
}
|
||||
.wr-alarm:before {
|
||||
content: '\e067';
|
||||
}
|
||||
.wr-person-1:before {
|
||||
content: '\e068';
|
||||
}
|
||||
.wr-open_in_new:before {
|
||||
content: '\e069';
|
||||
}
|
||||
.wr-uncheck:before {
|
||||
content: '\e06b';
|
||||
}
|
||||
.wr-thumb_up:before {
|
||||
content: '\e06c';
|
||||
}
|
||||
.wr-thumb_up_filled:before {
|
||||
content: '\e06d';
|
||||
}
|
||||
.wr-star:before {
|
||||
content: '\e06e';
|
||||
}
|
||||
.wr-star_filled:before {
|
||||
content: '\e06f';
|
||||
}
|
||||
.wr-cards:before {
|
||||
content: '\e072';
|
||||
}
|
||||
.wr-picture_error_filled:before {
|
||||
content: '\e076';
|
||||
}
|
||||
.wr-discount:before {
|
||||
content: '\e077';
|
||||
}
|
||||
47
style/theme.wxss
Normal file
47
style/theme.wxss
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/* 主题定制 */
|
||||
.t-input {
|
||||
--td-input-placeholder-text-color: #bbbbbb;
|
||||
--td-input-text-color: #333333;
|
||||
}
|
||||
|
||||
.t-tab-bar {
|
||||
--td-tab-bar-color: #bbb;
|
||||
--td-tab-bar-active-color: #333;
|
||||
}
|
||||
|
||||
.t-cascader {
|
||||
--td-cascader-active-color: #fa4126;
|
||||
}
|
||||
|
||||
.t-switch {
|
||||
--td-switch-checked-color: #34c759;
|
||||
}
|
||||
|
||||
.t-button {
|
||||
--td-button-font-weight: 500;
|
||||
--td-button-medium-font-size: 32rpx;
|
||||
--td-button-default-color: #fff;
|
||||
--td-button-default-bg-color: #fa4126;
|
||||
--td-button-default-border-color: #fa4126;
|
||||
--td-button-default-disabled-color: #fff;
|
||||
--td-button-default-disabled-bg: #cccccc;
|
||||
--td-button-default-disabled-border-color: #cccccc;
|
||||
--td-button-default-active-bg-color: #fa4126;
|
||||
--td-button-default-active-border-color: #fa4126;
|
||||
}
|
||||
|
||||
.t-textarea {
|
||||
--td-textarea-placeholder-color: #bbb;
|
||||
}
|
||||
|
||||
.t-checkbox {
|
||||
--td-checkbox-icon-checked-color: #fa4126;
|
||||
}
|
||||
|
||||
.dialog__button-confirm {
|
||||
color: #fa4126 !important;
|
||||
}
|
||||
|
||||
.dialog__button-cancel {
|
||||
color: #aeb3b7 !important;
|
||||
}
|
||||
29
utils/constant.js
Normal file
29
utils/constant.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
const _ = {
|
||||
// cdnHost: 'http://civcar2.zhonganonline.top/newslist',
|
||||
// apiHost: 'http://civcar2.zhonganonline.top/newslist',
|
||||
cdnHost: 'http://cdn.liiistem.cn/liiistem',
|
||||
apiHost: 'https://prxy.liiistem.cn/liiistem',
|
||||
};
|
||||
if (wx.getStorageSync('mode') == 'dev') {
|
||||
_.cdnHost = 'http://civcar2.zhonganonline.top/liiistem';
|
||||
_.apiHost = 'http://civcar2.zhonganonline.top/liiistem';
|
||||
}
|
||||
|
||||
export const STATUS_LIST = [{
|
||||
key: 'init',
|
||||
label: '待审核'
|
||||
},
|
||||
{
|
||||
key: 'resolve',
|
||||
label: '审核通过'
|
||||
},
|
||||
{
|
||||
key: 'reject',
|
||||
label: '审核未通过'
|
||||
},
|
||||
]
|
||||
export const STATUS_MAP = STATUS_LIST.reduce((r, c) => {
|
||||
r[c.key] = c;
|
||||
return r;
|
||||
}, {})
|
||||
export default _;
|
||||
162
utils/func.js
Normal file
162
utils/func.js
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
import C from './constant.js';
|
||||
export const getHost = () => {
|
||||
return C.apiHost;
|
||||
};
|
||||
export const isDev = () => {
|
||||
return true;
|
||||
}
|
||||
export const parseDate = (time, type = 1) => {
|
||||
const val = [time.getFullYear(), time.getMonth() + 1, time.getDate()].map((o) => { return o < 10 ? '0' + o : o });
|
||||
const val2 = [time.getHours(), time.getMinutes(), time.getSeconds()].map((o) => { return o < 10 ? '0' + o : o });
|
||||
if (type === 1) {
|
||||
return val.join('-');
|
||||
}
|
||||
if (type === 2) {
|
||||
return val2.join(':');
|
||||
}
|
||||
if (type === 3) {
|
||||
return [val[0], '年', val[1], '月', val[2], '日'].join('');
|
||||
}
|
||||
if (type === 4) {
|
||||
return val[0] + '年';
|
||||
}
|
||||
if (type === 5) {
|
||||
return [val[1], '月'].join('');
|
||||
}
|
||||
if (type === 6) {
|
||||
return [val[1], '月', val[2], '日'].join('');
|
||||
}
|
||||
if (type === 7) {
|
||||
return val.join('.');
|
||||
}
|
||||
return val.join('-') + ' ' + val2.join(':');
|
||||
}
|
||||
|
||||
|
||||
export const safeStrToDate = (str) => {
|
||||
const arr = str.split(/[-\ \:]/g);
|
||||
const arr2 = [0, 0, 0, 0, 0, 0];
|
||||
arr.map((one, idx) => {
|
||||
arr2[idx] = one * 1;
|
||||
});
|
||||
if (arr2[1] > 0) {
|
||||
arr2[1] -= 1;
|
||||
}
|
||||
return new Date(arr2[0], arr2[1], arr2[2], arr2[3], arr2[4], arr2[5]);
|
||||
}
|
||||
|
||||
export const sizeTool = (size) => {
|
||||
if (size > 1024 * 1024 * 1024) {
|
||||
return (size / 1024 / 1024 / 1024).toFixed(2) + 'G';
|
||||
}
|
||||
if (size > 1024 * 1024) {
|
||||
return (size / 1024 / 1024).toFixed(2) + 'M';
|
||||
}
|
||||
if (size > 1024) {
|
||||
return (size / 1024).toFixed(2) + 'K';
|
||||
}
|
||||
return size + 'B'
|
||||
}
|
||||
|
||||
export const getQueryString = (params) => {
|
||||
const list = [];
|
||||
for (const k in params) {
|
||||
if (!(params[k] == undefined || params[k] == null)) {
|
||||
list.push([encodeURIComponent(k), encodeURIComponent(params[k])].join('='));
|
||||
}
|
||||
}
|
||||
return list.join('&');
|
||||
}
|
||||
|
||||
export const parseQueryString = (str) => {
|
||||
const l = str.split('&');
|
||||
const m = {};
|
||||
l.forEach((o) => {
|
||||
const _ = o.split('=');
|
||||
m[decodeURIComponent(_[0])] = decodeURIComponent(_[1] || '');
|
||||
})
|
||||
return m;
|
||||
}
|
||||
|
||||
export const filterProperties = (obj, propKeys) => {
|
||||
if (propKeys.length == 0) {
|
||||
return { ...obj };
|
||||
}
|
||||
const reObj = {};
|
||||
propKeys.map((k) => {
|
||||
reObj[k] = obj[k];
|
||||
});
|
||||
return reObj;
|
||||
}
|
||||
|
||||
export const filterPropertiesList = (list, propKeys) => {
|
||||
return list.map((obj => filterProperties(obj, propKeys)));
|
||||
}
|
||||
|
||||
|
||||
export const secToTimeStr = (n) => {
|
||||
const h = Math.floor(n * 1.0 / 60 / 60);
|
||||
const m = Math.floor((n - h * 60 * 60) / 60);
|
||||
const s = n % 60;
|
||||
return h + '时' + m + '分' + s + '秒';
|
||||
}
|
||||
|
||||
export const dateToWeek = (date) => {
|
||||
const arr = '日一二三四五六'.split('');
|
||||
return arr[date.getDay()];
|
||||
}
|
||||
|
||||
export const fixPage = (pageData, oldPage) => {
|
||||
// console.log('fixPage', pageData.page, oldPage);
|
||||
const { page, pageSize, total } = pageData;
|
||||
if (total == 0) {
|
||||
return {
|
||||
...pageData,
|
||||
page: 1, pageSize, total: 0
|
||||
};
|
||||
}
|
||||
const maxPage = Math.ceil(total * 1.0 / pageSize);
|
||||
if (oldPage > maxPage) {
|
||||
return {
|
||||
...pageData,
|
||||
list: [],
|
||||
page: oldPage, pageSize, total: 0
|
||||
};
|
||||
}
|
||||
return {
|
||||
...pageData,
|
||||
page, pageSize, total
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// 分转元,并移除小数点后多余的0
|
||||
export const formatePrice = (price) => {
|
||||
return (price / 100).toFixed(2).replace(/\.00$/, '')
|
||||
}
|
||||
// 时间(12:22)加上分钟后的时间
|
||||
export const timeAddMinute = (time, minute) => {
|
||||
const tmpTime = safeStrToDate('2020-01-01 ' + time + ':00').getTime() + minute * 60 * 1000;
|
||||
return parseDate(new Date(tmpTime), 9);
|
||||
}
|
||||
|
||||
// 手机号隐藏中间几位
|
||||
export const hidePhone = (phone) => {
|
||||
return (phone || '').replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
|
||||
}
|
||||
|
||||
export const fix0 = (n) => {
|
||||
if (!/[0-9\.]+/.test(n + '')) {
|
||||
return 0;
|
||||
}
|
||||
const t = n + '';
|
||||
if (n.indexOf('.') == -1) {
|
||||
return t;
|
||||
}
|
||||
const tt = t.split('.');
|
||||
const f0 = (tt[1].split('').reverse().join('') * 1 + '').split('').reverse().join('');
|
||||
if (f0 == 0) {
|
||||
return tt[0];
|
||||
}
|
||||
return [tt[0], f0].join('.');
|
||||
}
|
||||
45
utils/getPermission.js
Normal file
45
utils/getPermission.js
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
const getPermission = ({ code, name }) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
wx.getSetting({
|
||||
success: (res) => {
|
||||
if (res.authSetting[code] === false) {
|
||||
wx.showModal({
|
||||
title: `获取${name}失败`,
|
||||
content: `获取${name}失败,请在【右上角】-小程序【设置】项中,将【${name}】开启。`,
|
||||
confirmText: '去设置',
|
||||
confirmColor: '#FA550F',
|
||||
cancelColor: '取消',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
wx.openSetting({
|
||||
success(settinRes) {
|
||||
if (settinRes.authSetting[code] === true) {
|
||||
resolve();
|
||||
} else {
|
||||
console.warn('用户未打开权限', name, code);
|
||||
reject();
|
||||
}
|
||||
},
|
||||
});
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
},
|
||||
fail() {
|
||||
reject();
|
||||
},
|
||||
});
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
},
|
||||
fail() {
|
||||
reject();
|
||||
},
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getPermission,
|
||||
};
|
||||
53
utils/log.js
Normal file
53
utils/log.js
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
const A = {
|
||||
isLog: false,
|
||||
logList: [],
|
||||
}
|
||||
A.info = (msg) => {
|
||||
if (A.isLog) {
|
||||
return;
|
||||
}
|
||||
console.log('info', msg);
|
||||
A.logList.push({
|
||||
time: new Date(),
|
||||
msg: msg,
|
||||
type: 'info',
|
||||
});
|
||||
// console.log('logList', A.logList);
|
||||
}
|
||||
A.warn = (msg) => {
|
||||
if (A.isLog) {
|
||||
return;
|
||||
}
|
||||
console.log('warn', msg);
|
||||
A.logList.push({
|
||||
time: new Date(),
|
||||
msg: msg,
|
||||
type: 'warn',
|
||||
});
|
||||
}
|
||||
A.error = (msg) => {
|
||||
if (A.isLog) {
|
||||
return;
|
||||
}
|
||||
console.log('error', msg);
|
||||
A.logList.push({
|
||||
time: new Date(),
|
||||
msg: msg,
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
A.getLogList = (type) => {
|
||||
if (type) {
|
||||
return A.logList.filter((o) => {
|
||||
return o.type == type;
|
||||
})
|
||||
}
|
||||
console.log('llllll', A.logList, type);
|
||||
return A.logList;
|
||||
}
|
||||
A.setIslog = (f) => {
|
||||
// console.log('setIslog', f);
|
||||
A.isLog = f;
|
||||
}
|
||||
|
||||
module.exports = A
|
||||
51
utils/mock.js
Normal file
51
utils/mock.js
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/**
|
||||
* 随机打散字符串
|
||||
* @param {number} n 长度
|
||||
* @param {string} str 字符串
|
||||
* @returns
|
||||
*/
|
||||
function generateMixed(n, str) {
|
||||
var res = '';
|
||||
for (var i = 0; i < n; i++) {
|
||||
var id = Math.ceil(Math.random() * 35);
|
||||
res += str[id];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成随机数
|
||||
* @param {number} min 最小值
|
||||
* @param {number} max 最大值
|
||||
* @returns
|
||||
*/
|
||||
function getRandomNum(min, max) {
|
||||
var range = max - min;
|
||||
var rand = Math.random();
|
||||
return min + Math.round(rand * range);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成随机IP
|
||||
* @returns
|
||||
*/
|
||||
function mockIp() {
|
||||
return `10.${getRandomNum(1, 254)}.${getRandomNum(1, 254)}.${getRandomNum(
|
||||
1,
|
||||
254,
|
||||
)}`;
|
||||
}
|
||||
|
||||
function mockReqId() {
|
||||
return `${getRandomNum(100000, 999999)}.${new Date().valueOf()}${getRandomNum(
|
||||
1000,
|
||||
9999,
|
||||
)}.${getRandomNum(10000000, 99999999)}`;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
generateMixed,
|
||||
mockIp,
|
||||
mockReqId,
|
||||
getRandomNum,
|
||||
};
|
||||
226
utils/request.js
Normal file
226
utils/request.js
Normal file
|
|
@ -0,0 +1,226 @@
|
|||
import * as F from './func.js';
|
||||
const Log = require('./log.js');
|
||||
import C from './constant.js';
|
||||
let lockToLogin = false;
|
||||
const login = () => {
|
||||
const user_id = wx.getStorageSync('user_id');
|
||||
if (user_id) {
|
||||
return Promise.resolve(user_id);
|
||||
}
|
||||
// return Promise.resolve();
|
||||
return new Promise((resolve, reject) => {
|
||||
wx.login({
|
||||
success({ code }) {
|
||||
console.log('aaaa', code);
|
||||
// code = 'test';
|
||||
// code:'test'
|
||||
post('/index.php/api/v1/wx_login', { code }, true).then(({ model }) => {
|
||||
console.log('wx_login', model);
|
||||
wx.setStorageSync('user_id', model.user_id);
|
||||
resolve(model);
|
||||
}).catch((e) => {
|
||||
reject(e)
|
||||
})
|
||||
},
|
||||
fail(e) {
|
||||
reject(e)
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
const post = (path, params, notLogin = false) => {
|
||||
Log.info('post 请求:' + path + 'params:' + JSON.stringify(params));
|
||||
const _ = ((resolve, reject) => {
|
||||
const user_id = wx.getStorageSync('user_id');
|
||||
if (!user_id && !notLogin) {
|
||||
return reject(-1002);
|
||||
}
|
||||
wx.request({
|
||||
url: F.getHost() + path,
|
||||
data: params,
|
||||
header: {
|
||||
Cookie: 'user_id=' + user_id,
|
||||
},
|
||||
method: 'POST',
|
||||
success: (res) => {
|
||||
console.log('res', res);
|
||||
const {
|
||||
data,
|
||||
statusCode,
|
||||
cookies
|
||||
} = res;
|
||||
if (statusCode != 200) {
|
||||
wx.showToast({
|
||||
icon:'none',
|
||||
title: 'statusCode:' + statusCode
|
||||
});
|
||||
Log.error('post 请求失败1:' + statusCode + '|' + path + ' params:' + JSON.stringify(params));
|
||||
reject(-1);
|
||||
} else {
|
||||
const message = data.errorMsg || data.message;
|
||||
const errorCode = data.errorCode;
|
||||
if (errorCode == -1000) {
|
||||
wx.showToast({
|
||||
icon:'none',
|
||||
title: "登录超时,请重新登录"
|
||||
});
|
||||
if (!lockToLogin) {
|
||||
lockToLogin = true;
|
||||
wx.navigateTo({
|
||||
url: '/pages/login/index'
|
||||
});
|
||||
setTimeout(() => {
|
||||
lockToLogin = false;
|
||||
}, 1000)
|
||||
}
|
||||
reject(-4);
|
||||
} else if (errorCode < 0) {
|
||||
wx.showToast({
|
||||
icon:'none',
|
||||
title: message || errorCode + '请求失败' ,
|
||||
});
|
||||
Log.error('post 请求失败2:' + message + '|' + path + ' params:' + JSON.stringify(params));
|
||||
reject(-3);
|
||||
} else {
|
||||
resolve(data);
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: ({
|
||||
errMsg,
|
||||
errno
|
||||
}) => {
|
||||
wx.showToast({
|
||||
icon:'none',
|
||||
title: '接口异常:' + errMsg
|
||||
});
|
||||
console.error('post fail:', errMsg, errno);
|
||||
Log.error('post error:' + errMsg + '|errno:' + errno + '|' + path + ' params:' + JSON.stringify(params));
|
||||
reject(-2);
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
if (notLogin) {
|
||||
return new Promise(_);
|
||||
} else {
|
||||
return login().then(() => new Promise(_));
|
||||
}
|
||||
}
|
||||
const get = (path, params, notLogin = false) => {
|
||||
Log.info('get 请求:' + path + 'params:' + JSON.stringify(params));
|
||||
const _ = ((resolve, reject) => {
|
||||
const user_id = wx.getStorageSync('user_id');
|
||||
if (!user_id && !notLogin) {
|
||||
return reject(-1002);
|
||||
}
|
||||
wx.request({
|
||||
url: F.getHost() + path,
|
||||
data: params,
|
||||
header: {
|
||||
Cookie: 'user_id=' + user_id,
|
||||
},
|
||||
method: 'GET',
|
||||
success: ({
|
||||
data,
|
||||
statusCode,
|
||||
cookies
|
||||
}) => {
|
||||
if (statusCode != 200) {
|
||||
wx.showToast({
|
||||
icon:'none',
|
||||
title: 'statusCode:' + statusCode
|
||||
});
|
||||
Log.error('get 请求失败1:' + statusCode + '|' + path + ' params:' + JSON.stringify(params));
|
||||
reject(-1);
|
||||
} else {
|
||||
const message = data.errorMsg || data.message;
|
||||
const errorCode = data.errorCode;
|
||||
if (errorCode == -1000) {
|
||||
wx.showToast({
|
||||
icon:'none',
|
||||
title: "登录超时,请重新登录"
|
||||
});
|
||||
if (!lockToLogin) {
|
||||
lockToLogin = true;
|
||||
wx.navigateTo({
|
||||
url: '/pages/login/index'
|
||||
});
|
||||
setTimeout(() => {
|
||||
lockToLogin = false;
|
||||
}, 1000)
|
||||
}
|
||||
reject(-4);
|
||||
} else if (errorCode < 0) {
|
||||
wx.showToast({
|
||||
icon:'none',
|
||||
title: message || errorCode + '请求失败' ,
|
||||
});
|
||||
Log.error('get 请求失败2:' + message + '|' + path + ' params:' + JSON.stringify(params));
|
||||
reject(-3);
|
||||
} else {
|
||||
resolve(data);
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: ({
|
||||
errMsg,
|
||||
errno
|
||||
}) => {
|
||||
wx.showToast({
|
||||
icon:'none',
|
||||
title: '接口异常:' + errMsg
|
||||
});
|
||||
console.error('get fail:', errMsg, errno);
|
||||
Log.error('get error:' + errMsg + '|errno:' + errno + '|' + path + ' params:' + JSON.stringify(params));
|
||||
reject(-2);
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
if (notLogin) {
|
||||
return new Promise(_);
|
||||
} else {
|
||||
return login().then(() => new Promise(_));
|
||||
}
|
||||
}
|
||||
const upload = (params, name, filePath, processCb) => {
|
||||
const _ = new Promise((resolve, reject) => {
|
||||
const user_id = wx.getStorageSync('user_id');
|
||||
const task = wx.uploadFile({
|
||||
url: F.getHost() + '/index.php/api/v1/wx_upload',
|
||||
formData: params,
|
||||
name,
|
||||
filePath,
|
||||
header: {
|
||||
Cookie: 'user_id=' + user_id,
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
timeout: 120000,
|
||||
method: 'POST',
|
||||
success: (res) => {
|
||||
resolve(res);
|
||||
},
|
||||
fail: (res) => {
|
||||
const {
|
||||
errMsg,
|
||||
errno
|
||||
} = res;
|
||||
console.error('post fail:', errMsg, errno);
|
||||
Log.error('upload post fail:' + errMsg + '|errno' + errno);
|
||||
reject(res);
|
||||
}
|
||||
});
|
||||
if (processCb) {
|
||||
task.onProgressUpdate(processCb);
|
||||
}
|
||||
})
|
||||
|
||||
return login().then(() => _);
|
||||
}
|
||||
export default {
|
||||
login,
|
||||
post,
|
||||
get,
|
||||
upload,
|
||||
};
|
||||
203
utils/requestAct1.js
Normal file
203
utils/requestAct1.js
Normal file
|
|
@ -0,0 +1,203 @@
|
|||
import * as F from './func.js';
|
||||
const Log = require('./log.js');
|
||||
import C from './constant.js';
|
||||
let lockToLogin = false;
|
||||
const login = () => {
|
||||
return Promise.resolve();
|
||||
}
|
||||
const post = (path, params, notLogin = false) => {
|
||||
Log.info('post 请求:' + path + 'params:' + JSON.stringify(params));
|
||||
const _ = new Promise((resolve, reject) => {
|
||||
const user_id = wx.getStorageSync('act_user_id');
|
||||
if (!user_id && !notLogin) {
|
||||
return reject(-1001);
|
||||
}
|
||||
wx.request({
|
||||
url: F.getHost() + path,
|
||||
data: params,
|
||||
header: {
|
||||
Cookie: 'act_user_id=' + user_id,
|
||||
},
|
||||
method: 'POST',
|
||||
success: (res) => {
|
||||
console.log('res', res);
|
||||
const {
|
||||
data,
|
||||
statusCode,
|
||||
cookies
|
||||
} = res;
|
||||
if (statusCode != 200) {
|
||||
wx.showToast({
|
||||
icon: 'none',
|
||||
title: 'statusCode:' + statusCode
|
||||
});
|
||||
Log.error('post 请求失败1:' + statusCode + '|' + path + ' params:' + JSON.stringify(params));
|
||||
reject(-1);
|
||||
} else {
|
||||
const message = data.errorMsg || data.message;
|
||||
const errorCode = data.errorCode;
|
||||
if (errorCode == -1000) {
|
||||
wx.showToast({
|
||||
icon: 'none',
|
||||
title: "登录超时,请重新登录"
|
||||
});
|
||||
if (!lockToLogin) {
|
||||
lockToLogin = true;
|
||||
wx.navigateTo({
|
||||
url: '/pages/login/index'
|
||||
});
|
||||
setTimeout(() => {
|
||||
lockToLogin = false;
|
||||
}, 1000)
|
||||
}
|
||||
reject(-4);
|
||||
} else if (errorCode < 0) {
|
||||
wx.showToast({
|
||||
icon: 'none',
|
||||
title: message || errorCode + '请求失败'
|
||||
});
|
||||
Log.error('post 请求失败2:' + message + '|' + path + ' params:' + JSON.stringify(params));
|
||||
reject(-3);
|
||||
} else {
|
||||
resolve(data);
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: ({
|
||||
errMsg,
|
||||
errno
|
||||
}) => {
|
||||
wx.showToast({
|
||||
icon: 'none',
|
||||
title: '接口异常:' + errMsg
|
||||
});
|
||||
console.error('post fail:', errMsg, errno);
|
||||
Log.error('post error:' + errMsg + '|errno:' + errno + '|' + path + ' params:' + JSON.stringify(params));
|
||||
reject(-2);
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
if (notLogin) {
|
||||
return _;
|
||||
} else {
|
||||
return login().then(() => _);
|
||||
}
|
||||
}
|
||||
const get = (path, params, notLogin = false) => {
|
||||
Log.info('get 请求:' + path + 'params:' + JSON.stringify(params));
|
||||
const _ = new Promise((resolve, reject) => {
|
||||
const user_id = wx.getStorageSync('act_user_id');
|
||||
if (!user_id && !notLogin) {
|
||||
return reject(-1001);
|
||||
}
|
||||
wx.request({
|
||||
url: F.getHost() + path,
|
||||
data: params,
|
||||
header: {
|
||||
Cookie: 'act_user_id=' + user_id,
|
||||
},
|
||||
method: 'GET',
|
||||
success: ({
|
||||
data,
|
||||
statusCode,
|
||||
cookies
|
||||
}) => {
|
||||
if (statusCode != 200) {
|
||||
wx.showToast({
|
||||
icon: 'none',
|
||||
title: 'statusCode:' + statusCode
|
||||
});
|
||||
Log.error('get 请求失败1:' + statusCode + '|' + path + ' params:' + JSON.stringify(params));
|
||||
reject(-1);
|
||||
} else {
|
||||
const message = data.errorMsg || data.message;
|
||||
const errorCode = data.errorCode;
|
||||
if (errorCode == -1000) {
|
||||
wx.showToast({
|
||||
icon: 'none',
|
||||
title: "登录超时,请重新登录"
|
||||
});
|
||||
if (!lockToLogin) {
|
||||
lockToLogin = true;
|
||||
wx.navigateTo({
|
||||
url: '/pages/login/index'
|
||||
});
|
||||
setTimeout(() => {
|
||||
lockToLogin = false;
|
||||
}, 1000)
|
||||
}
|
||||
reject(-4);
|
||||
} else if (errorCode < 0) {
|
||||
wx.showToast({
|
||||
icon: 'none',
|
||||
title: message || errorCode + '请求失败'
|
||||
});
|
||||
Log.error('get 请求失败2:' + message + '|' + path + ' params:' + JSON.stringify(params));
|
||||
reject(-3);
|
||||
} else {
|
||||
resolve(data);
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: ({
|
||||
errMsg,
|
||||
errno
|
||||
}) => {
|
||||
wx.showToast({
|
||||
icon: 'none',
|
||||
title: '接口异常:' + errMsg
|
||||
});
|
||||
console.error('get fail:', errMsg, errno);
|
||||
Log.error('get error:' + errMsg + '|errno:' + errno + '|' + path + ' params:' + JSON.stringify(params));
|
||||
reject(-2);
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
if (notLogin) {
|
||||
return _;
|
||||
} else {
|
||||
return login().then(() => _);
|
||||
}
|
||||
}
|
||||
const upload = (params, name, filePath, processCb) => {
|
||||
const _ = new Promise((resolve, reject) => {
|
||||
const user_id = wx.getStorageSync('act_user_id');
|
||||
const task = wx.uploadFile({
|
||||
url: F.getHost() + '/index.php/api/act1/wx_upload',
|
||||
formData: params,
|
||||
name,
|
||||
filePath,
|
||||
header: {
|
||||
Cookie: 'act_user_id=' + user_id,
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
timeout: 120000,
|
||||
method: 'POST',
|
||||
success: (res) => {
|
||||
resolve(res);
|
||||
},
|
||||
fail: (res) => {
|
||||
const {
|
||||
errorMsg,
|
||||
errorCode
|
||||
} = res;
|
||||
console.error('post fail:', errorMsg, errorCode);
|
||||
Log.error('upload post fail:' + errorMsg + '|errorCode' + errorCode);
|
||||
reject(res);
|
||||
}
|
||||
});
|
||||
if (processCb) {
|
||||
task.onProgressUpdate(processCb);
|
||||
}
|
||||
})
|
||||
|
||||
return login().then(() => _);
|
||||
}
|
||||
export default {
|
||||
login,
|
||||
post,
|
||||
get,
|
||||
upload,
|
||||
};
|
||||
133
utils/util.js
Normal file
133
utils/util.js
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
import dayjs from 'dayjs';
|
||||
|
||||
const formatTime = (date, template) => dayjs(date).format(template);
|
||||
|
||||
/**
|
||||
* 格式化价格数额为字符串
|
||||
* 可对小数部分进行填充,默认不填充
|
||||
* @param price 价格数额,以分为单位!
|
||||
* @param fill 是否填充小数部分 0-不填充 1-填充第一位小数 2-填充两位小数
|
||||
*/
|
||||
function priceFormat(price, fill = 0) {
|
||||
if (isNaN(price) || price === null || price === Infinity) {
|
||||
return price;
|
||||
}
|
||||
|
||||
let priceFormatValue = Math.round(parseFloat(`${price}`) * 10 ** 8) / 10 ** 8; // 恢复精度丢失
|
||||
priceFormatValue = `${Math.ceil(priceFormatValue) / 100}`; // 向上取整,单位转换为元,转换为字符串
|
||||
if (fill > 0) {
|
||||
// 补充小数位数
|
||||
if (priceFormatValue.indexOf('.') === -1) {
|
||||
priceFormatValue = `${priceFormatValue}.`;
|
||||
}
|
||||
const n = fill - priceFormatValue.split('.')[1]?.length;
|
||||
for (let i = 0; i < n; i++) {
|
||||
priceFormatValue = `${priceFormatValue}0`;
|
||||
}
|
||||
}
|
||||
return priceFormatValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取cdn裁剪后链接
|
||||
*
|
||||
* @param {string} url 基础链接
|
||||
* @param {number} width 宽度,单位px
|
||||
* @param {number} [height] 可选,高度,不填时与width同值
|
||||
*/
|
||||
const cosThumb = (url, width, height = width) => {
|
||||
if (url.indexOf('?') > -1) {
|
||||
return url;
|
||||
}
|
||||
|
||||
if (url.indexOf('http://') === 0) {
|
||||
url = url.replace('http://', 'https://');
|
||||
}
|
||||
|
||||
return `${url}?imageMogr2/thumbnail/${~~width}x${~~height}`;
|
||||
};
|
||||
|
||||
const get = (source, paths, defaultValue) => {
|
||||
if (typeof paths === 'string') {
|
||||
paths = paths
|
||||
.replace(/\[/g, '.')
|
||||
.replace(/\]/g, '')
|
||||
.split('.')
|
||||
.filter(Boolean);
|
||||
}
|
||||
const { length } = paths;
|
||||
let index = 0;
|
||||
while (source != null && index < length) {
|
||||
source = source[paths[index++]];
|
||||
}
|
||||
return source === undefined || index === 0 ? defaultValue : source;
|
||||
};
|
||||
let systemWidth = 0;
|
||||
/** 获取系统宽度,为了减少启动消耗所以在函数里边做初始化 */
|
||||
export const loadSystemWidth = () => {
|
||||
if (systemWidth) {
|
||||
return systemWidth;
|
||||
}
|
||||
|
||||
try {
|
||||
({ screenWidth: systemWidth, pixelRatio } = wx.getSystemInfoSync());
|
||||
} catch (e) {
|
||||
systemWidth = 0;
|
||||
}
|
||||
return systemWidth;
|
||||
};
|
||||
|
||||
/**
|
||||
* 转换rpx为px
|
||||
*
|
||||
* @description
|
||||
* 什么时候用?
|
||||
* - 布局(width: 172rpx)已经写好, 某些组件只接受px作为style或者prop指定
|
||||
*
|
||||
*/
|
||||
const rpx2px = (rpx, round = false) => {
|
||||
loadSystemWidth();
|
||||
|
||||
// px / systemWidth = rpx / 750
|
||||
const result = (rpx * systemWidth) / 750;
|
||||
|
||||
if (round) {
|
||||
return Math.floor(result);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* 手机号码*加密函数
|
||||
* @param {string} phone 电话号
|
||||
* @returns
|
||||
*/
|
||||
const phoneEncryption = (phone) => {
|
||||
return phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
|
||||
};
|
||||
|
||||
// 内置手机号正则字符串
|
||||
const innerPhoneReg =
|
||||
'^1(?:3\\d|4[4-9]|5[0-35-9]|6[67]|7[0-8]|8\\d|9\\d)\\d{8}$';
|
||||
|
||||
/**
|
||||
* 手机号正则校验
|
||||
* @param phone 手机号
|
||||
* @param phoneReg 正则字符串
|
||||
* @returns true - 校验通过 false - 校验失败
|
||||
*/
|
||||
const phoneRegCheck = (phone) => {
|
||||
const phoneRegExp = new RegExp(innerPhoneReg);
|
||||
return phoneRegExp.test(phone);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
formatTime,
|
||||
priceFormat,
|
||||
cosThumb,
|
||||
get,
|
||||
rpx2px,
|
||||
phoneEncryption,
|
||||
phoneRegCheck,
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue