Skip to content

Commit

Permalink
chore(business): move to setup sugar (#2643)
Browse files Browse the repository at this point in the history
  • Loading branch information
eiinu authored Nov 8, 2023
1 parent 9b8905d commit a0a2a6b
Show file tree
Hide file tree
Showing 48 changed files with 6,174 additions and 7,203 deletions.
460 changes: 213 additions & 247 deletions packages/nutui-taro-demo/src/business/pages/address/index.vue

Large diffs are not rendered by default.

109 changes: 45 additions & 64 deletions packages/nutui-taro-demo/src/business/pages/addresslist/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,73 +41,54 @@
</div>
</template>

<script lang="ts">
<script setup lang="ts">
import { reactive, ref } from 'vue';
import Taro from '@tarojs/taro';
import Header from '../../../components/header.vue';
export default {
components: { Header },
setup() {
const env = Taro.getEnv();
const data = ref([
{
testid: 3,
testaddressName: '姓名',
phone: '123****4567',
defaultAddress: false,
fullAddress: '北京市通州区测试测试测试测试测试测试测试测试测试'
},
{
testid: 4,
testaddressName: '姓名',
phone: '123****4567',
defaultAddress: true,
fullAddress: '北京市通州区测试测试测试测试测试测试测试测试测试'
}
]);
const dataOptions = reactive({
id: 'testid',
addressDetail: 'testaddressDetail',
addressName: 'testaddressName'
});
const clickItem = () => {
console.log('Click To Address');
};
const delClick = () => {
console.log('Click To Delete');
};
const editClick = () => {
console.log('Click To Edit');
};
const copyClick = () => {
console.log('Click To Copy');
};
const setClick = () => {
console.log('Click On Settings');
};
const delClickLong = () => {
console.log('Click On DelClickLong');
};
const delClickSwipe = () => {
console.log('Click On DelClickSwipe');
};
const addAddress = () => {
console.log('Click To Add');
};
return {
clickItem,
data,
delClick,
editClick,
copyClick,
setClick,
delClickLong,
delClickSwipe,
addAddress,
dataOptions,
env
};
const env = Taro.getEnv();
const data = ref([
{
testid: 3,
testaddressName: '姓名',
phone: '123****4567',
defaultAddress: false,
fullAddress: '北京市通州区测试测试测试测试测试测试测试测试测试'
},
{
testid: 4,
testaddressName: '姓名',
phone: '123****4567',
defaultAddress: true,
fullAddress: '北京市通州区测试测试测试测试测试测试测试测试测试'
}
]);
const dataOptions = reactive({
id: 'testid',
addressDetail: 'testaddressDetail',
addressName: 'testaddressName'
});
const clickItem = () => {
console.log('Click To Address');
};
const delClick = () => {
console.log('Click To Delete');
};
const editClick = () => {
console.log('Click To Edit');
};
const copyClick = () => {
console.log('Click To Copy');
};
const setClick = () => {
console.log('Click On Settings');
};
const delClickLong = () => {
console.log('Click On DelClickLong');
};
const delClickSwipe = () => {
console.log('Click On DelClickSwipe');
};
const addAddress = () => {
console.log('Click To Add');
};
</script>
29 changes: 8 additions & 21 deletions packages/nutui-taro-demo/src/business/pages/barrage/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,17 @@
</div>
</template>

<script lang="ts">
<script setup lang="ts">
import { ref } from 'vue';
import Taro from '@tarojs/taro';
import Header from '../../../components/header.vue';
export default {
components: { Header },
setup() {
const env = Taro.getEnv();
const inputVal = ref<any>('');
const danmu = ref<any>(null);
let list = ref(['画美不看', '不明觉厉', '喜大普奔', '男默女泪', '累觉不爱', '爷青结']);
function addDanmu() {
let n = Math.random();
danmu.value.add('随机——' + String(n).substr(2, 10));
}
return {
inputVal,
danmu,
list,
addDanmu,
env
};
}
};
const env = Taro.getEnv();
const danmu = ref<any>(null);
let list = ref(['画美不看', '不明觉厉', '喜大普奔', '男默女泪', '累觉不爱', '爷青结']);
function addDanmu() {
let n = Math.random();
danmu.value.add('随机——' + String(n).substr(2, 10));
}
</script>

<style lang="scss">
Expand Down
78 changes: 32 additions & 46 deletions packages/nutui-taro-demo/src/business/pages/category/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<div class="demo full category-demo" :class="{ web: env === 'WEB' }">
<Header v-if="env === 'WEB'" />
<h2>经典分类模式</h2>
<nut-category :category="category" @change="change">
<nut-category-pane :categoryChild="categoryChild1" @onChange="onChange"> </nut-category-pane>
<nut-category :category="data.category" @change="change">
<nut-category-pane :categoryChild="data.categoryChild1" @onChange="onChange"> </nut-category-pane>
</nut-category>

<h2>只显示文字</h2>
<nut-category :category="category" @change="changeText">
<nut-category-pane type="text" :categoryChild="categoryChild2" @onChange="onChange"> </nut-category-pane
<nut-category :category="data.category" @change="changeText">
<nut-category-pane type="text" :categoryChild="data.categoryChild2" @onChange="onChange"> </nut-category-pane
></nut-category>

<h2>自定义分类</h2>
Expand All @@ -18,57 +18,43 @@
</div>
</template>

<script lang="ts">
<script setup lang="ts">
import { categoryInfo, categoryChild, customCategory } from './data';
import { reactive, toRefs, onMounted } from 'vue';
import { reactive, onMounted } from 'vue';
import Taro from '@tarojs/taro';
import Header from '../../../components/header.vue';
export default {
components: { Header },
setup() {
const env = Taro.getEnv();
const data = reactive({
category: [{}],
categoryChild1: [{}],
customCategory: [{}],
categoryChild2: [{}]
});
const env = Taro.getEnv();
const data = reactive({
category: [{}],
categoryChild1: [{}],
customCategory: [{}],
categoryChild2: [{}]
});
onMounted(() => {
setTimeout(() => {
data.category = categoryInfo.category;
data.categoryChild1 = categoryChild;
data.customCategory = customCategory;
data.categoryChild2 = categoryChild;
}, 500);
});
onMounted(() => {
setTimeout(() => {
data.category = categoryInfo.category;
data.categoryChild1 = categoryChild;
data.customCategory = customCategory;
data.categoryChild2 = categoryChild;
}, 500);
});
const change = (index: any) => {
data.categoryChild1 = [].concat(data.category[index]?.children as any);
};
const changeText = (index: any) => {
data.categoryChild2 = [].concat(data.category[index]?.children as any);
};
const change = (index: any) => {
data.categoryChild1 = [].concat(data.category[index]?.children as any);
};
const changeCustom = () => {
console.log('点击分类数据');
};
const changeText = (index: any) => {
data.categoryChild2 = [].concat(data.category[index]?.children as any);
};
const onChange = () => {
console.log('当前分类数据');
};
const changeCustom = () => {
console.log('点击分类数据');
};
return {
change,
onChange,
changeText,
changeCustom,
...toRefs(data),
env
};
}
const onChange = () => {
console.log('当前分类数据');
};
</script>

Expand Down
60 changes: 24 additions & 36 deletions packages/nutui-taro-demo/src/business/pages/comment/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,46 +62,34 @@
</nut-cell>
</div>
</template>
<script lang="ts">
import { defineComponent, onMounted, ref } from 'vue';
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import Taro from '@tarojs/taro';
import Header from '../../../components/header.vue';
export default defineComponent({
components: { Header },
setup() {
const env = Taro.getEnv();
let cmt = ref({});
const env = Taro.getEnv();
let cmt = ref({});
const handleclick = (info: any) => {
console.log('进行跳转', info);
};
const handleclick = (info: any) => {
console.log('进行跳转', info);
};
onMounted(() => {
getData();
});
const getData = () => {
Taro.request({
method: 'GET',
url: 'https://storage.360buyimg.com/nutui/3x/comment_data.json',
success: (res) => {
res.data.Comment.info.avatar =
'https://img14.360buyimg.com/imagetools/jfs/t1/167902/2/8762/791358/603742d7E9b4275e3/e09d8f9a8bf4c0ef.png';
cmt.value = res.data.Comment;
}
});
};
onMounted(() => {
getData();
});
const clickImages = (imgs: any) => {
console.log('进行图片展示', imgs);
};
const getData = () => {
Taro.request({
method: 'GET',
url: 'https://storage.360buyimg.com/nutui/3x/comment_data.json',
success: (res) => {
res.data.Comment.info.avatar =
'https://img14.360buyimg.com/imagetools/jfs/t1/167902/2/8762/791358/603742d7E9b4275e3/e09d8f9a8bf4c0ef.png';
cmt.value = res.data.Comment;
}
});
};
return {
cmt,
handleclick,
clickImages,
env
};
}
});
const clickImages = (imgs: any) => {
console.log('进行图片展示', imgs);
};
</script>
Loading

0 comments on commit a0a2a6b

Please sign in to comment.