适配小程序代码结构
This commit is contained in:
133
unpackage/dist/dev/mp-weixin/pages/grid/grid.js
vendored
Normal file
133
unpackage/dist/dev/mp-weixin/pages/grid/grid.js
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const common_assets = require("../../common/assets.js");
|
||||
const _sfc_main = {
|
||||
data() {
|
||||
return {
|
||||
gridList: [],
|
||||
current: 0,
|
||||
hasLogin: false
|
||||
};
|
||||
},
|
||||
onShow() {
|
||||
this.hasLogin = common_vendor.tr.getCurrentUserInfo().tokenExpired > Date.now();
|
||||
},
|
||||
onLoad() {
|
||||
let gridList = [];
|
||||
for (var i = 0; i < 3; i++) {
|
||||
gridList.push(this.$t("grid.visibleToAll"));
|
||||
}
|
||||
for (var i = 0; i < 3; i++) {
|
||||
gridList.push(this.$t("grid.invisibleToTourists"));
|
||||
}
|
||||
for (var i = 0; i < 3; i++) {
|
||||
gridList.push(this.$t("grid.adminVisible"));
|
||||
}
|
||||
this.gridList = gridList;
|
||||
},
|
||||
methods: {
|
||||
change(e) {
|
||||
common_vendor.index.showToast({
|
||||
title: this.$t("grid.clickTip") + ` ${e.detail.index + 1} ` + this.$t("grid.clickTipGrid"),
|
||||
icon: "none"
|
||||
});
|
||||
},
|
||||
/**
|
||||
* banner加载后触发的回调
|
||||
*/
|
||||
onqueryload(data) {
|
||||
},
|
||||
changeSwiper(e) {
|
||||
this.current = e.detail.current;
|
||||
},
|
||||
/**
|
||||
* 点击banner的处理
|
||||
*/
|
||||
clickBannerItem(item) {
|
||||
if (item.open_url) {
|
||||
common_vendor.index.navigateTo({
|
||||
url: "/uni_modules/uni-id-pages/pages/common/webview/webview?url=" + item.open_url + "&title=" + item.title,
|
||||
success: (res) => {
|
||||
},
|
||||
fail: () => {
|
||||
},
|
||||
complete: () => {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
if (!Array) {
|
||||
const _easycom_unicloud_db2 = common_vendor.resolveComponent("unicloud-db");
|
||||
const _easycom_uni_grid_item2 = common_vendor.resolveComponent("uni-grid-item");
|
||||
const _easycom_uni_grid2 = common_vendor.resolveComponent("uni-grid");
|
||||
(_easycom_unicloud_db2 + _easycom_uni_grid_item2 + _easycom_uni_grid2)();
|
||||
}
|
||||
const _easycom_unicloud_db = () => "../../node-modules/@dcloudio/uni-components/lib/unicloud-db/unicloud-db.js";
|
||||
const _easycom_uni_grid_item = () => "../../uni_modules/uni-grid/components/uni-grid-item/uni-grid-item.js";
|
||||
const _easycom_uni_grid = () => "../../uni_modules/uni-grid/components/uni-grid/uni-grid.js";
|
||||
if (!Math) {
|
||||
(_easycom_unicloud_db + _easycom_uni_grid_item + _easycom_uni_grid)();
|
||||
}
|
||||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
return {
|
||||
a: common_vendor.w(({
|
||||
data,
|
||||
loading,
|
||||
error,
|
||||
options
|
||||
}, s0, i0) => {
|
||||
return common_vendor.e({
|
||||
a: !(loading || data.length)
|
||||
}, !(loading || data.length) ? {
|
||||
b: common_assets._imports_0
|
||||
} : {
|
||||
c: common_vendor.f(data, (item, index, i1) => {
|
||||
return {
|
||||
a: item.bannerfile.url,
|
||||
b: common_vendor.o(($event) => $options.clickBannerItem(item), item._id),
|
||||
c: item._id
|
||||
};
|
||||
}),
|
||||
d: common_vendor.o((...args) => $options.changeSwiper && $options.changeSwiper(...args)),
|
||||
e: $data.current
|
||||
}, {
|
||||
f: i0,
|
||||
g: s0
|
||||
});
|
||||
}, {
|
||||
name: "d",
|
||||
path: "a",
|
||||
vueId: "0d0199f0-0"
|
||||
}),
|
||||
b: common_vendor.sr("bannerdb", "0d0199f0-0"),
|
||||
c: common_vendor.o($options.onqueryload),
|
||||
d: common_vendor.p({
|
||||
collection: "opendb-banner",
|
||||
field: "_id,bannerfile,open_url,title"
|
||||
}),
|
||||
e: common_vendor.t(_ctx.$t("grid.grid")),
|
||||
f: common_vendor.f($data.gridList, (item, i, i0) => {
|
||||
return common_vendor.e({
|
||||
a: i < 3 || i > 2 && i < 6 && $data.hasLogin || i > 5 && _ctx.uniIDHasRole("admin")
|
||||
}, i < 3 || i > 2 && i < 6 && $data.hasLogin || i > 5 && _ctx.uniIDHasRole("admin") ? {
|
||||
b: common_vendor.t(i + 1),
|
||||
c: common_vendor.t(item),
|
||||
d: i,
|
||||
e: "0d0199f0-2-" + i0 + ",0d0199f0-1",
|
||||
f: common_vendor.p({
|
||||
index: i
|
||||
})
|
||||
} : {});
|
||||
}),
|
||||
g: common_vendor.o($options.change),
|
||||
h: common_vendor.p({
|
||||
column: 3,
|
||||
highlight: true
|
||||
})
|
||||
};
|
||||
}
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
|
||||
wx.createPage(MiniProgramPage);
|
||||
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/grid/grid.js.map
|
||||
7
unpackage/dist/dev/mp-weixin/pages/grid/grid.json
vendored
Normal file
7
unpackage/dist/dev/mp-weixin/pages/grid/grid.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"unicloud-db": "../../node-modules/@dcloudio/uni-components/lib/unicloud-db/unicloud-db",
|
||||
"uni-grid-item": "../../uni_modules/uni-grid/components/uni-grid-item/uni-grid-item",
|
||||
"uni-grid": "../../uni_modules/uni-grid/components/uni-grid/uni-grid"
|
||||
}
|
||||
}
|
||||
1
unpackage/dist/dev/mp-weixin/pages/grid/grid.wxml
vendored
Normal file
1
unpackage/dist/dev/mp-weixin/pages/grid/grid.wxml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<view class="warp"><unicloud-db wx:if="{{d}}" class="r" u-s="{{['d']}}" u-r="bannerdb" bindload="{{c}}" u-i="0d0199f0-0" bind:__l="__l" u-p="{{d}}"><view wx:for="{{a}}" wx:for-item="v0" wx:key="f" slot="{{v0.g}}"><image wx:if="{{v0.a}}" class="banner-image" src="{{v0.b}}" mode="aspectFill" draggable="{{false}}"/><swiper wx:else class="swiper-box" bindchange="{{v0.d}}" current="{{v0.e}}" indicator-dots><swiper-item wx:for="{{v0.c}}" wx:for-item="item" wx:key="c"><image class="banner-image" src="{{item.a}}" mode="aspectFill" bindtap="{{item.b}}" draggable="{{false}}"/></swiper-item></swiper></view></unicloud-db><view class="section-box"><text class="decoration"></text><text class="section-text">{{e}}</text></view><view class="example-body"><uni-grid wx:if="{{h}}" u-s="{{['d']}}" bindchange="{{g}}" u-i="0d0199f0-1" bind:__l="__l" u-p="{{h}}"><block wx:for="{{f}}" wx:for-item="item"><uni-grid-item wx:if="{{item.a}}" u-s="{{['d']}}" key="{{item.d}}" u-i="{{item.e}}" bind:__l="__l" u-p="{{item.f}}"><view class="grid-item-box" style="background-color:#fff"><text class="big-number">{{item.b}}</text><text class="text">{{item.c}}</text></view></uni-grid-item></block></uni-grid></view></view>
|
||||
103
unpackage/dist/dev/mp-weixin/pages/grid/grid.wxss
vendored
Normal file
103
unpackage/dist/dev/mp-weixin/pages/grid/grid.wxss
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
|
||||
page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
background-color: #fff;
|
||||
min-height: 100%;
|
||||
height: auto;
|
||||
}
|
||||
view {
|
||||
font-size: 14px;
|
||||
line-height: inherit;
|
||||
}
|
||||
.example-body {
|
||||
|
||||
display: flex;
|
||||
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
padding: 0;
|
||||
font-size: 14px;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
.section-box{
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
padding: 20rpx;
|
||||
}
|
||||
.decoration{
|
||||
width: 4px;
|
||||
height: 12px;
|
||||
border-radius: 10px;
|
||||
background-color: #2979ff;
|
||||
}
|
||||
.section-text{
|
||||
color: #333;
|
||||
margin-left: 15rpx;
|
||||
}
|
||||
.example-body {
|
||||
flex-direction: column;
|
||||
padding: 15px;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
.image {
|
||||
width: 50rpx;
|
||||
height: 50rpx;
|
||||
}
|
||||
.big-number{
|
||||
font-size: 50rpx;
|
||||
font-weight: 700;
|
||||
font-stretch: condensed;
|
||||
font-style:oblique;
|
||||
}
|
||||
.text {
|
||||
text-align: center;
|
||||
font-size: 26rpx;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
.example-body {
|
||||
|
||||
display: block;
|
||||
}
|
||||
.grid-item-box {
|
||||
flex: 1;
|
||||
|
||||
display: flex;
|
||||
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 15px 0;
|
||||
}
|
||||
.banner-image {
|
||||
width: 100%;
|
||||
height: 400rpx;
|
||||
}
|
||||
.swiper-box {
|
||||
height: 400rpx;
|
||||
}
|
||||
.search-icons {
|
||||
padding: 16rpx;
|
||||
}
|
||||
.search-container-bar {
|
||||
|
||||
display: flex;
|
||||
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 10;
|
||||
background-color: #fff;
|
||||
}
|
||||
.uni-searchbar__box {
|
||||
border-width: 0;
|
||||
}
|
||||
.uni-input-placeholder {
|
||||
font-size: 28rpx;
|
||||
}
|
||||
Reference in New Issue
Block a user