init project
This commit is contained in:
10
miniprogram/pages/main/travel/luggage/index.json
Normal file
10
miniprogram/pages/main/travel/luggage/index.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||
"t-input": "tdesign-miniprogram/input/input",
|
||||
"t-navbar": "tdesign-miniprogram/navbar/navbar",
|
||||
"t-button": "tdesign-miniprogram/button/button",
|
||||
"t-checkbox": "tdesign-miniprogram/checkbox/checkbox",
|
||||
"t-checkbox-group": "tdesign-miniprogram/checkbox-group/checkbox-group"
|
||||
}
|
||||
}
|
||||
88
miniprogram/pages/main/travel/luggage/index.less
Normal file
88
miniprogram/pages/main/travel/luggage/index.less
Normal file
@ -0,0 +1,88 @@
|
||||
.luggage {
|
||||
|
||||
.tips {
|
||||
color: #777;
|
||||
margin: .5rem 0;
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.items {
|
||||
gap: 8px;
|
||||
width: calc(100% - 64rpx);
|
||||
margin: 12rpx auto;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
|
||||
.item {
|
||||
--td-checkbox-vertical-padding: 12rpx 24rpx;
|
||||
|
||||
flex: 1;
|
||||
margin: 0;
|
||||
border: 3rpx solid #CCC;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
word-break: break-all;
|
||||
border-radius: 12rpx;
|
||||
|
||||
&:first-child {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
&.active {
|
||||
border-color: var(--td-brand-color, #0052d9);
|
||||
|
||||
&::after {
|
||||
content: "";
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
display: block;
|
||||
position: absolute;
|
||||
border-width: 24px 24px 24px 0;
|
||||
border-style: solid;
|
||||
border-color: var(--td-brand-color);
|
||||
border-bottom-color: transparent;
|
||||
border-right-color: transparent;
|
||||
}
|
||||
}
|
||||
|
||||
.icon {
|
||||
top: 1px;
|
||||
left: 1px;
|
||||
color: var(--td-bg-color-container, #fff);
|
||||
z-index: 1;
|
||||
position: absolute;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.checkbox {
|
||||
height: calc(100% - 24rpx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.add-container {
|
||||
left: 0;
|
||||
right: 0;
|
||||
color: #333;
|
||||
bottom: 0;
|
||||
display: flex;
|
||||
padding: 20rpx;
|
||||
position: fixed;
|
||||
border-top: 1px solid rgba(0, 0, 0, .1);
|
||||
background: rgba(240, 240, 240, .8);
|
||||
box-sizing: border-box;
|
||||
align-items: center;
|
||||
padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
|
||||
backdrop-filter: blur(10px);
|
||||
|
||||
.input {
|
||||
--td-input-vertical-padding: 8rpx;
|
||||
margin-right: .5rem;
|
||||
border-radius: 5px;
|
||||
}
|
||||
}
|
||||
86
miniprogram/pages/main/travel/luggage/index.ts
Normal file
86
miniprogram/pages/main/travel/luggage/index.ts
Normal file
@ -0,0 +1,86 @@
|
||||
// pages/main/travel/luggage/index.ts
|
||||
|
||||
import { LuggageItem } from "..";
|
||||
import config from "../../../../config/index"
|
||||
|
||||
interface ILuggageData {
|
||||
name: string;
|
||||
value: LuggageItem[];
|
||||
keyboardHeight: number;
|
||||
addValue: string;
|
||||
}
|
||||
|
||||
Page({
|
||||
data: <ILuggageData>{
|
||||
name: "",
|
||||
value: [],
|
||||
keyboardHeight: 0,
|
||||
addValue: ""
|
||||
},
|
||||
onLoad() {
|
||||
wx.onKeyboardHeightChange(res => {
|
||||
this.setData({
|
||||
keyboardHeight: res.height
|
||||
})
|
||||
})
|
||||
},
|
||||
onShow() {
|
||||
const store = wx.getStorageSync("luggage");
|
||||
const value = store.luggage[store.name];
|
||||
this.setData({
|
||||
value,
|
||||
name: store.name === "gao" ? "小糕" : "夜雨"
|
||||
});
|
||||
},
|
||||
doBack() {
|
||||
const store = wx.getStorageSync("luggage");
|
||||
store.luggage[store.name] = this.data.value;
|
||||
wx.request({
|
||||
url: `${config.url}/journal/travel/luggage/update`,
|
||||
method: "POST",
|
||||
header: {
|
||||
Key: wx.getStorageSync("key")
|
||||
},
|
||||
data: store.luggage,
|
||||
success: () => {
|
||||
wx.navigateBack();
|
||||
}
|
||||
});
|
||||
},
|
||||
onTapItem(e: WechatMiniprogram.BaseEvent) {
|
||||
const index = e.currentTarget.dataset.index;
|
||||
this.data.value[index].isTaken = !this.data.value[index].isTaken;
|
||||
this.setData({ value: this.data.value });
|
||||
},
|
||||
showMenu(e: WechatMiniprogram.BaseEvent) {
|
||||
const index = e.currentTarget.dataset.index;
|
||||
wx.showActionSheet({
|
||||
itemList: ["删除"],
|
||||
itemColor: "red",
|
||||
success: () => {
|
||||
this.data.value.splice(index, 1);
|
||||
this.setData({ value: this.data.value })
|
||||
}
|
||||
});
|
||||
},
|
||||
onInputFocus() {
|
||||
this.setData({
|
||||
keyboardHeight: this.data.keyboardHeight
|
||||
})
|
||||
},
|
||||
onInputBlur() {
|
||||
this.setData({
|
||||
keyboardHeight: 0
|
||||
})
|
||||
},
|
||||
add() {
|
||||
this.data.value.push({
|
||||
name: this.data.addValue,
|
||||
isTaken: false
|
||||
})
|
||||
this.setData({
|
||||
value: this.data.value,
|
||||
addValue: ""
|
||||
})
|
||||
}
|
||||
})
|
||||
39
miniprogram/pages/main/travel/luggage/index.wxml
Normal file
39
miniprogram/pages/main/travel/luggage/index.wxml
Normal file
@ -0,0 +1,39 @@
|
||||
<!--pages/main/travel/luggage/index.wxml-->
|
||||
<wxs module="_"> module.exports.contain = function(arr, key) { return arr.indexOf(key) > -1 } </wxs>
|
||||
|
||||
<view class="custom-navbar">
|
||||
<t-navbar title="{{name}}的旅行装备" bind:go-back="doBack" delta="0" left-arrow />
|
||||
</view>
|
||||
<view class="luggage">
|
||||
<view class="tips">tips: 勾选表示已携带,返回自动保存</view>
|
||||
<t-checkbox-group class="items">
|
||||
<view
|
||||
class="item {{item.isTaken ? 'active' : ''}}"
|
||||
wx:for="{{value}}"
|
||||
wx:key="index"
|
||||
data-index="{{index}}"
|
||||
bindtap="onTapItem"
|
||||
bindlongpress="showMenu"
|
||||
>
|
||||
<t-icon wx:if="{{item.isTaken}}" name="check" class="icon" ariaHidden="{{true}}" />
|
||||
<t-checkbox
|
||||
class="checkbox"
|
||||
value="{{item.isTaken}}"
|
||||
label="{{item.name}}"
|
||||
icon="none"
|
||||
borderless
|
||||
/>
|
||||
</view>
|
||||
</t-checkbox-group>
|
||||
</view>
|
||||
<view class="add-container" style="transform: translateY(-{{keyboardHeight}}px)">
|
||||
<t-input
|
||||
class="input"
|
||||
placeholder="请输入新的物品"
|
||||
cursor-spacing="20"
|
||||
adjust-position="{{false}}"
|
||||
model:value="{{addValue}}"
|
||||
borderless
|
||||
/>
|
||||
<t-button size="small" theme="primary" bindtap="add" disabled="{{!addValue}}">添加</t-button>
|
||||
</view>
|
||||
Reference in New Issue
Block a user