fix 任务工单

This commit is contained in:
sdaduanbilei 2025-12-08 15:09:41 +08:00
parent 98af0c8d3e
commit 0fd5d81f09
14 changed files with 265 additions and 94 deletions

13
app.js
View File

@ -17,6 +17,13 @@ App({
if (res.data.user.id) {
wx.setStorageSync('user', res.data.user)
wx.setStorageSync('token', res.data.token)
publisher.emit("login");
// 生成邀请码
api('/personal/inviteCode/code','GET').then(res => {
if (res.code === 200){
wx.setStorageSync('inviteCode', res.data)
}
})
} else {
wx.showModal({
title: '提示',
@ -52,7 +59,7 @@ App({
wx.setStorageSync('city', res.data)
const tmp = wx.getStorageSync('weather')
if (tmp) {
publisher.emit("login");
console.log("succ");
} else {
api('/auth/getWeather', 'GET', res.data).then(res => {
if (res.code === 200) {
@ -67,10 +74,14 @@ App({
console.log(err);
}
})
},
fail: err => {
console.log(err);
}
})
}
})

View File

@ -194,6 +194,10 @@ page {
.blue {
color: blue;
}
.font-black {
color: #000000E6 !important;
}
.font-12{
font-size: 12px;

View File

@ -33,7 +33,7 @@
</view>
</view>
<view class="mt-32 flex flex-center flex-justify-end">
<view class="flex flex-center" data-item="{{item}}" bind:tap="like">
<view class="flex flex-center" data-item="{{item}}" catch:tap="like">
<t-icon name="{{item.hasLiked === 1 ?'thumb-up-filled':'thumb-up'}}" style="color: {{item.hasLiked === 1 ?'red':''}};" ></t-icon>
<view class="ml-16">{{item.likeCount}}</view>
</view>

View File

@ -1,4 +1,6 @@
const { api } = require("../../utils/api")
const {
api
} = require("../../utils/api")
// pages/community/info.js
Page({
@ -7,9 +9,9 @@ Page({
* 页面的初始数据
*/
data: {
id : '',
info:null,
content:'',
id: '',
info: null,
content: '',
},
@ -22,38 +24,50 @@ Page({
this.fetchInfo()
},
fetchInfo(){
api('/post/detail','GET',{id: this.data.id}).then(res => {
if (res.code== 200){
fetchInfo() {
api('/post/detail', 'GET', {
id: this.data.id
}).then(res => {
if (res.code == 200) {
const tmp = res.data
this.setData({info:tmp})
this.setData({
info: tmp
})
}
})
},
input(e){
input(e) {
const value = e.detail.value
console.log(value);
this.data.content = value
},
add(){
const data = {content: this.data.content, postId: this.data.id,parentId: this.data.id,rootId:this.data.id}
add() {
const data = {
content: this.data.content,
postId: this.data.id,
parentId: this.data.id,
rootId: this.data.id
}
console.log(data);
api('/comment/add','POST',data,'json').then(res => {
if (res.code === 200){
api('/comment/add', 'POST', data, 'json').then(res => {
if (res.code === 200) {
this.fetchInfo()
}
})
},
goPreview(e){
console.log(e);
const url = e.currentTarget.dataset.url
wx.navigateTo({
url: '../preview/index?url=' + url,
goPreview(e) {
// 在上一页的 js 文件中
const currentUrl = e.currentTarget.dataset.url; // 获取当前点击的图片链接
const list = this.data.info.imgList.map(e => e.url)
wx.previewImage({
current: currentUrl, // 当前显示图片的http链接
urls: list// 需要预览的图片http链接列表
})
},
/**
* 生命周期函数--监听页面初次渲染完成

View File

@ -13,10 +13,10 @@
<view>{{info.content}}</view>
</view>
<view class="mt-16">
<view wx:if="{{info.imgList.length == 1}}">
<view wx:for="{{info.imgList}}">
<image src="{{info.imgList[0].url}}" style="border-radius: 16rpx; height: 50vw; width: 100%;" mode="aspectFill"></image>
</view>
<view wx:if="{{info.imgList.length == 1}}" data-url="{{info.imgList[0].url}}" bind:tap="goPreview">
<image src="{{info.imgList[0].url}}" style="border-radius: 16rpx; height: 50vw; width: 100%;" mode="aspectFill"></image>
</view>
<view wx:else class="grid">
<view class="item" wx:for="{{info.imgList}}" data-url="{{item.url}}" bind:tap="goPreview">

View File

@ -16,15 +16,22 @@ Page({
rightList: [],
leftHeight: 0,
rightHeight: 0,
hotList:[],
info:null
hotList: [],
info: null,
needCare: 0,
inviteCode: ''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
const code = options.inviteCode
if (code) {
api('/personal/inviteCode/accept', 'GET', {
inviteCode: code
})
}
},
/**
@ -42,20 +49,62 @@ Page({
this.init()
},
init(){
init() {
const tmp = wx.getStorageSync('weather')
if(tmp){
this.setData({info:tmp})
if (tmp) {
this.setData({
info: tmp
})
} else {
wx.getFuzzyLocation({
type: 'wgs84',
success(res) {
const data = {
latitude: res.latitude + "",
longitude: res.longitude + ""
}
api('/auth/getLocation', 'GET', data).then(res => {
if (res.code === 200) {
wx.setStorageSync('city', res.data)
api('/auth/getWeather', 'GET', res.data).then(res => {
if (res.code === 200) {
wx.setStorageSync('weather', res.data)
this.setData({info:res.data})
}
})
}
})
},
fail(err) {
console.log(err);
}
})
}
const city = wx.getStorageSync('city')
api('/auth/getWeather', 'GET', city).then(res => {
const inviteCode = wx.getStorageSync('inviteCode')
if (inviteCode) {
this.setData({
inviteCode: inviteCode
})
}
api('/plant/needCare', 'GET').then(res => {
if (res.code === 200) {
wx.setStorageSync('weather', res.data)
this.setData({
needCare: res.data
})
}
})
},
goTask() {
wx.switchTab({
url: '../garden/index',
})
},
fetchList() {
api('/plant/page', 'POST', {
current: 0,
@ -70,7 +119,10 @@ Page({
this.fetchHotList()
return
}
this.setData({leftList:[],rightList:[]})
this.setData({
leftList: [],
rightList: []
})
const tmps = res.data.list.map(e => {
e.pic = e.imgList[0].url
e.cover = e.imgList[0]
@ -78,7 +130,7 @@ Page({
})
this.addItems(tmps)
this.setData({
list: tmps
})
@ -86,14 +138,20 @@ Page({
})
},
fetchHotList(){
api('/library/list','POST',{isHot:0,current:0,pageSize:6},'json').then(res => {
if (res.code === 200){
fetchHotList() {
api('/library/list', 'POST', {
isHot: 0,
current: 0,
pageSize: 6
}, 'json').then(res => {
if (res.code === 200) {
const data = res.data.list.map(e => {
e.pic = e.imgList[0].url
return e
})
this.setData({hotList:data})
this.setData({
hotList: data
})
}
})
},
@ -101,26 +159,26 @@ Page({
addItems(newItems) {
let h1 = 0;
let h2 = 0;
newItems.forEach((item,index) => {
newItems.forEach((item, index) => {
// 动态获取图片尺寸
if (index % 2 === 0) {
this.data.leftList.push(item);
h1 += item.cover.height / item.cover.width;
} else {
this.data.rightList.push(item);
h2 += item.cover.height / item.cover.width;
}
this.setData({
leftList: this.data.leftList,
rightList: this.data.rightList,
});
if (index % 2 === 0) {
this.data.leftList.push(item);
h1 += item.cover.height / item.cover.width;
} else {
this.data.rightList.push(item);
h2 += item.cover.height / item.cover.width;
}
this.setData({
leftList: this.data.leftList,
rightList: this.data.rightList,
});
});
},
goInfo(e){
goInfo(e) {
console.log(e);
const id = e.currentTarget.dataset.id
const id = e.currentTarget.dataset.id
wx.navigateTo({
url: '../garden/info?id=' + id,
})
@ -142,7 +200,7 @@ Page({
goAdd() {
const tmp = wx.getStorageSync('user')
if (tmp.phone.length === 0){
if (tmp.phone.length === 0) {
wx.navigateTo({
url: '../login/index',
})
@ -184,6 +242,18 @@ Page({
* 用户点击右上角分享
*/
onShareAppMessage() {
return {
title: '发现一个宝藏养花神器',
imageUrl: "https://res.catter.cn/pub/2025/12/08/20251208112039694.png",
path: '/pages/index/index?inviteCode=' + this.data.inviteCode
};
},
onShareTimeline() {
return {
title: '发现一个宝藏养花神器',
imageUrl: "https://res.catter.cn/pub/2025/12/08/20251208112039694.png",
path: '/pages/index/index?inviteCode=' + this.data.inviteCode
};
}
})

View File

@ -2,16 +2,17 @@
<view>
<!-- top -->
<view class="top primary-bg">
<view style="padding-top: 128rpx; padding-left: 32rpx;" class="white" wx:if="{{info}}">
<view class="bold font-16">{{info.weather}} {{info.windDirection}}风{{info.windPower}}级</view>
<view>
<view class="flex flex-center flex-justify-start">
<t-icon wx:if="{{info.weather === '雾'}}" name="fog" size="34"></t-icon>
<view class="bold mt-16 ml-16" style="font-size: 40px;">{{info.temperature}} ℃</view>
<view style="padding-top: 128rpx; min-height: 200rpx; padding-left: 32rpx;" class="white">
<view class="bold font-16" wx:if="{{info}}">{{info.weather}} {{info.windDirection}}风{{info.windPower}}级</view>
<view wx:if="{{info}}">
<view class="flex flex-center flex-justify-start flex-aligin-center mt-16">
<t-icon wx:if="{{info.weather === '雾'}}" name="fog" size="34"></t-icon>
<t-icon wx:if="{{info.weather === '多云'}}" name="cloud" size="34"></t-icon>
<view class="bold ml-16" style="font-size: 40px;" >{{info.temperature}} ℃</view>
</view>
<view wx:if="{{leftList.length > 0}}">
<view> 今日需养护 2 株植物</view>
<view class="mt-16 font-12" style="color: #E2B43F;">龟背竹长期未更新照片</view>
<view wx:if="{{leftList.length > 0}}" bind:tap="goTask" class="flex flex-center flex-justify-start">
<view> 今日需养护 {{needCare}} 株植物</view>
<t-icon name="chevron-right" class="ml-5"></t-icon>
</view>
</view>
</view>
@ -19,9 +20,9 @@
<view style="height: 89vh;" wx:if="{{list.length > 0}}">
<view class="waterfall" scroll-y="{{true}}">
<view class="column">
<block wx:for="{{leftList}}" wx:key="id" >
<block wx:for="{{leftList}}" wx:key="id">
<view class="card mb-16" data-id="{{item.id}}" bind:tap="goInfo">
<view class="img-wrapper" >
<view class="img-wrapper">
<image src="{{item.pic}}" mode="widthFix" class="img"></image>
<view class="overlay" style="margin-bottom: 26rpx;">
<view class="font-14 bold">{{item.name}}</view>
@ -51,9 +52,9 @@
</view>
<view class="column">
<block wx:for="{{rightList}}" wx:key="id" >
<block wx:for="{{rightList}}" wx:key="id">
<view class="card mb-16" data-id="{{item.id}}" bind:tap="goInfo">
<view class="img-wrapper" >
<view class="img-wrapper">
<image src="{{item.pic}}" mode="widthFix" class="img"></image>
<view class="overlay" style="margin-bottom: 26rpx;">
<view class="font-14 bold">{{item.name}}</view>

View File

@ -1,6 +1,26 @@
<!--pages/preview/index.wxml-->
<view class="flex flex-center">
<view style="height: 80vh;" class="flex flex-center">
<image src=" {{url}}" style="width: 100vw;height: 50vh;" mode="aspectFill" show-menu-by-longpress></image>
<view style="height: 80vh; width: 100vw;" class="flex flex-center">
<movable-area style="width: 100%; height: 100%;">
<movable-view
direction="all"
scale="{{true}}"
min-scale="0.5"
max-scale="5"
scale-value="{{scale}}"
style="width: 100%; height: 100%; display:flex; align-items:center; justify-content:center;"
>
<image
src="{{url}}"
style="width: 100%; height: 100%;"
mode="aspectFit"
show-menu-by-longpress
></image>
</movable-view>
</movable-area>
</view>
</view>

View File

@ -1,3 +1,5 @@
const { api } = require("../../utils/api")
// pages/store/index.js
Page({
@ -41,7 +43,15 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
this.fetchList()
},
fetchList(){
api('/claim/list','POST',{current:0,pageSize:10,name:'',keyword:''},'json').then(res => {
if (res.code === 200){
console.log(res);
}
})
},
/**

View File

@ -2,7 +2,7 @@
<view>
<view class="flex flex-center primary-bg padding">
<view class="white">
我的兑换币 1 枚
我的阳光值 1 枚
</view>
<view class="ml-16" style="color: orange;">
邀请好友获取更多兑换币

View File

@ -1,4 +1,6 @@
const { api } = require("../../utils/api")
const {
api
} = require("../../utils/api")
const config = require("../../config/config")
// pages/user/index.js
Page({
@ -7,8 +9,9 @@ Page({
* 页面的初始数据
*/
data: {
user:null,
info:null
user: null,
info: null,
inviteCode: ''
},
/**
@ -16,9 +19,15 @@ Page({
*/
onLoad(options) {
const tmp = wx.getStorageSync('user')
if (tmp){
this.setData({user:tmp})
if (tmp) {
this.setData({
user: tmp
})
}
const inviteCode = wx.getStorageSync('inviteCode')
this.setData({
inviteCode: inviteCode
})
},
/**
@ -34,11 +43,13 @@ Page({
onShow() {
this.fetchInfo()
},
fetchInfo(){
api('/personal/personal','GET').then(res => {
if (res.code === 200){
fetchInfo() {
api('/personal/personal', 'GET').then(res => {
if (res.code === 200) {
const tmps = res.data
this.setData({info:res.data})
this.setData({
info: tmps
})
}
})
},
@ -62,7 +73,7 @@ Page({
tmps.avatar = data.data.file
tmps.avatarId = data.data.file.id
_this.setData({
user:tmps
user: tmps
})
_this.update()
}
@ -70,27 +81,27 @@ Page({
})
},
update(){
api('/user/update','POST',this.data.user,"json").then(res => {
if (res.code === 200){
update() {
api('/user/update', 'POST', this.data.user, "json").then(res => {
if (res.code === 200) {
}
})
},
goStore(){
goStore() {
wx.navigateTo({
url: '../store/index',
})
},
goAbout(){
goAbout() {
wx.navigateTo({
url: '../user/about',
})
},
goPrivate(){
goPrivate() {
wx.openPrivacyContract()
},
@ -127,6 +138,18 @@ Page({
* 用户点击右上角分享
*/
onShareAppMessage() {
return {
title: '发现一个宝藏养花神器',
imageUrl: "https://res.catter.cn/pub/2025/12/08/20251208112039694.png",
path: '/pages/index/index?inviteCode=' + this.data.inviteCode
};
},
onShareTimeline() {
return {
title: '发现一个宝藏养花神器',
imageUrl: "https://res.catter.cn/pub/2025/12/08/20251208112039694.png",
path: '/pages/index/index?inviteCode=' + this.data.inviteCode
};
}
})

View File

@ -2,7 +2,7 @@
<view>
<!-- top -->
<view class="bg">
<view wx:if="{{info}}" >
<view wx:if="{{info}}">
<view class="flex flex-center flex-justify-start" style="margin-top:128rpx;">
<view style="width: 140rpx;height:140rpx;" class="flex flex-center flex-justify-start full-width ">
<button class="avatar-wrapper" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar" style="background-color: red;">
@ -29,6 +29,11 @@
<view class="white-bg padding mt-16 row">
<!-- dash -->
<view class=" flex flex-center flex-justify-around mt-32">
<view class="flex flex-center flex-col">
<view class="font-16 bold" style="font-size: 20px;">{{info.pointsCount}}</view>
<view class="font-12">我的阳光值</view>
</view>
<view class="flex flex-center flex-col">
<view class="font-16 bold" style="font-size: 20px;">{{info.plantCount}}</view>
<view class="font-12">我的植物</view>
@ -85,7 +90,13 @@
<t-cell title="提醒设置" hover arrow />
<t-cell title="加入微信群" hover arrow bind:tap="goAbout" />
<t-cell title="用户协议" hover arrow bind:tap="goPrivate" />
<t-cell title="邀请好友" hover arrow bordered="{{false}}" description="成功邀请可以获得稀有种子" />
<button class="avatar-wrapper " style="width: 100%;" open-type="share">
<view class="flex flex-center flex-justify-between">
<view class="font-16 font-black " style="width: 100%; text-align: left; padding: 0 32rpx;">邀请好友</view>
<t-icon name="chevron-right" size="24" style="padding-right: 36rpx; color:#00000069;"></t-icon>
</view>
<view class="font-14 " style="color: #00000099; text-align: left; padding: 0 32rpx;">成功邀请可以免费兑换植物</view>
</button>
</view>
</view>
<view class="padding"></view>

View File

@ -20,7 +20,7 @@ button::after {
.avatar-wrapper {
padding: 0;
color: #000000E6 !important;
background-color: rebeccapurple !important;
width: 280rpx;
}

View File

@ -23,12 +23,19 @@
"condition": {
"miniprogram": {
"list": [
{
"name": "pages/index/index",
"pathName": "pages/index/index",
"query": "inviteCode=7NQJHCKT",
"scene": null,
"launchMode": "default"
},
{
"name": "pages/store/index",
"pathName": "pages/store/index",
"query": "",
"scene": null,
"launchMode": "default"
"launchMode": "default",
"scene": null
}
]
}