찾다
위챗 애플릿미니 프로그램 개발작은 프로그램의 자동 로딩을 위한 완전한 코드

이 기사는 작은 프로그램의 자동 로딩을 위한 완전한 코드를 제공합니다. 이는 특정 참조 가치가 있습니다. 도움이 필요한 친구가 도움이 되기를 바랍니다.

<!-- 头部 -->
<view class=&#39;head&#39;>
<view data-order=&#39;1&#39; bindtap=&#39;clickorder&#39;><text class=&#39;{{a}}&#39;>售中({{count}})</text></view>
<view data-order=&#39;2&#39; bindtap=&#39;clickorder&#39;><text class=&#39;{{b}}&#39;>已售({{counts}})</text></view>
</view>
<block wx:if="{{choose==1}}">
<block wx:for="{{goods_list}}">
<view class=&#39;shop-middle&#39;>
<view class=&#39;shop-img&#39;>
<!-- <image mode=&#39;widthFix&#39; src="https://sungroow.com/{{item.image_middle}}"></image> -->
<image src="https://sungroow.com{{item.image_thumb}}"></image>
</view>
<view class=&#39;shop-num&#39;>
<view>{{item.goods_name}}</view>
<view>¥ {{item.price}}</view>
</view>
<view class="but_all">
<block wx:if="{{item.is_sale==1}}">
<button size="mini" type="default" data-goods="{{item.goods_id}}" bindtap=&#39;onsale&#39;>下架</button>
</block>
<block wx:if="{{item.is_sale==0}}">
<button size="mini" type="default" data-goods="{{item.goods_id}}" bindtap=&#39;onsale&#39;>上架</button>
</block>
</view>
</view>
</block>
</block>
 
<block wx:if="{{choose==2}}">
<block wx:for="{{order_list}}">
<view class=&#39;shop-middle&#39;>
<view class=&#39;shop-img&#39;>
<!-- <image mode=&#39;widthFix&#39; src="https://sungroow.com/{{item.image_middle}}"></image> -->
<image src="https://sungroow.com{{item.image_thumb}}"></image>
</view>
<view class=&#39;shop-num&#39;>
<view>{{item.goods_name}}</view>
<view>x{{item.goods_number}}件</view>
<view>¥ {{item.goods_price}}</view>
</view>
<view class="but_all">
<block wx:if="{{item.is_sale==1}}">
<button size="mini" type="default" data-goods="{{item.goods_id}}" bindtap=&#39;onsale&#39;>下架</button>
</block>
<block wx:if="{{item.is_sale==0}}">
<button size="mini" type="default" data-goods="{{item.goods_id}}" bindtap=&#39;onsale&#39;>上架</button>
</block>
</view>
</view>
</block>
</block>
 
<view class=&#39;{{show}}&#39;>商品加载完毕</view>
 
 
 
/* //顶部 */
.head {
position: relative;
width: 100%;
height: 60rpx;
flex-direction: row;
display: flex;
align-items: center;
/* left: -20rpx; */
border-bottom: 1.4px #e6e6e6 solid;
border-top: 1.4px #e6e6e6 solid;
}
 
.head view {
position: relative;
/* margin-left: 52rpx; */
font-size: 27rpx;
color: #414141;
display: flex;
justify-content:center;
width: 50%;
 
}
.line{
border-bottom:1.4px #414141 solid;
}
 
/*主体 */
.shop-middle{
position: relative;
height: 170rpx;
width: 100%;
border-bottom: 1.4px #e6e6e6 solid;
border-top: 1.4px #e6e6e6 solid;
padding-top:10rpx;
 
}
 
.shop_rank image{
position: relative;
height:32rpx;
width:74rpx;
 
}
 
.shop-img {
display: flex;
flex-direction: row;
width: 25%;
font-size: 29rpx;
}
 
.shop-img image {
height:160rpx;
width:160rpx;
margin-right:22rpx;
 
}
 
.shop-num {
justify-content: space-between;
position: absolute;
left: 200rpx;
width: 75%;
display: flex;
flex-direction: column;
font-size: 25rpx;
top:0rpx;
}
 
.shop-num view {
position: relative;
margin-top: 15rpx;
overflow: hidden;
}
.but_all{
position:relative;
 
left:620rpx;
top:-50rpx;
 
}
 
.is-show{
position: relative;
width: 100%;
height: 70rpx;
display:flex;
justify-content:center;
align-items:center;
font-size:28rpx;
/* border-top:1.4px #e6e6e6 solid; */
 
}
.is-hide{
display: hidden;
}
 
var app = getApp()
var com = require(&#39;../../../utils/util.js&#39;)
Page({
 
/**
* 页面的初始数据
*/
data: {
show: &#39;is-hide&#39;,
page:0,
pages:0,
a: &#39;line&#39;,
b: &#39;&#39;,
goods_list:[],
count:0,
counts:0,
choose:1,
order_list:[]
},
// 头部
clickorder(e) {
var that = this
console.log(e)
var id = e.currentTarget.dataset.order
if (id == 1) {
that.setData({
a: &#39;line&#39;,
b: &#39;&#39;,
c: &#39;&#39;,
d: &#39;&#39;,
e: &#39;&#39;,
f: &#39;&#39;,
choose:1
})
that.index(that.data.store_id,that.data.page);
} else if (id == 2) { //待付款
var that = this
that.setData({
a: &#39;&#39;,
b: &#39;line&#39;,
c: &#39;&#39;,
d: &#39;&#39;,
e: &#39;&#39;,
f: &#39;&#39;,
choose:2
})
that.getindex(that.data.page)
}
},
//获取全部订单
getindex: function (page) {
var that = this;
var list = that.data.order_list;
console.log(list)
var lists = [];
var key = wx.getStorageSync(&#39;key&#39;)
console.log(that.data.page)
that.setData({
key: key
})
com.POST({
url: &#39;Order/wait_pay_all&#39;,
data: {
key: that.data.key,
pay_status: 2,
shipping_status: 1,
order_status: 1,
limit:10,
page:page
},
success: function (msg) {
console.log(msg.data.datas)
if (msg.data.code == 200) {
lists = list.concat(msg.data.datas)
that.setData({
page:that.data.page+1,
counts: msg.data.datas[0].countsss,
order_list: lists,
show: &#39;is-show&#39;
})
} else {
// wx.showToast({
// title: &#39;暂无订单&#39;,
// icon: &#39;none&#39;,
// duration: 2000
// })
}
}
})
 
},
//上架
onsale(e){
var goods_id=e.currentTarget.dataset.goods
 
//最新
var that = this
wx.getStorage({
key: &#39;key&#39;,
success: function (res) {
com.POST({
url: &#39;Goods/on_sale&#39;,
data: {
key: res.data,
goods_id: goods_id
},
success: function (msg) {
console.log(msg)
if (msg.data.code == 200) {
wx.showModal({
title: &#39;温馨提示&#39;,
content: msg.data.datas,
success: function (res) {
if (res.confirm) {
wx.switchTab({
url: &#39;/pages/my/index&#39;
})
}
}
 
})
} else {
wx.showModal({
title: &#39;温馨提示&#39;,
content: msg.data.error,
success: function (res) {
if (res.confirm) {
wx.switchTab({
url: &#39;/pages/my/index&#39;
})
}
}
})
}
}
})
}
})
},
 
//设计师所有的商品
 
index(options,page){
//最新
var that = this
var list = that.data.goods_list;
var lists = [];
console.log(that.data.page)
wx.getStorage({
key: &#39;key&#39;,
success: function (res) {
com.POST({
url: &#39;Goods/goods_list&#39;,
data: {
key: res.data,
store_id: options.store_id,
limit: 10,
page: page,
is_sale: 1
},
success: function (msg) {
console.log(msg)
if (msg.data.code == 200) {
lists = list.concat(msg.data.datas)
console.log(lists)
that.setData({
page:that.data.page +1,
goods_list: lists,
count: msg.data.datas[0].count,
show: &#39;is-show&#39;
})
// wx.startPullDownRefresh();
} else {
// wx.showModal({
// title: &#39;温馨提示&#39;,
// content: msg.data.error,
// success: function (res) {
// if (res.confirm) {
// // wx.switchTab({
// // url: &#39;/pages/index/index&#39;
// // })
// }
// }
// })
}
}
})
}
})
},
 
/**
* 生命周期函数--监听页面加载
*/
onShow: function (options) {
this.index(this.data.store_id, this.data.pages)
this.getindex(this.data.pages)
},
 
onLoad: function (options){
this.setData({
store_id: options
})
this.index(options, this.data.pages)
this.getindex(this.data.pages)
},
 
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
 
/**
* 生命周期函数--监听页面显示
*/
 
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
 
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
 
//滚动到底部触发事件
onReachBottom: function () {
 
let that = this;
console.log("上拉", that.data.pages)
// if (that.data.searchLoading && !that.data.searchLoadingComplete) {
that.setData({
pages: that.data.pages + 1, //每次触发上拉事件,把searchPageNum+1
// isFromSearch: false //触发到上拉事件,把isFromSearch设为为false
});
// console.log(that.data.counts, that.data.count)
if (that.data.choose==2){
that.getindex(that.data.pages)
} else if (that.data.choose == 1){
that.index(that.data.store_id, that.data.pages)
}
 
},
 
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
wx.stopPullDownRefresh()
},
 
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})

관련 추천:

WeChat 미니 프로그램 예시: 마키의 애니메이션 효과 구현 방법(코드 포함)

WeChat 미니 프로그램 예시: 즐겨찾기 사진 수집 및 싫어하는 사진과 사진 전환의 기능적 효과

위 내용은 작은 프로그램의 자동 로딩을 위한 완전한 코드의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

인기 기사

R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
4 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 최고의 그래픽 설정
4 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 아무도들을 수없는 경우 오디오를 수정하는 방법
4 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25 : Myrise에서 모든 것을 잠금 해제하는 방법
1 몇 달 전By尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

Eclipse용 SAP NetWeaver 서버 어댑터

Eclipse용 SAP NetWeaver 서버 어댑터

Eclipse를 SAP NetWeaver 애플리케이션 서버와 통합합니다.

Dreamweaver Mac版

Dreamweaver Mac版

시각적 웹 개발 도구

안전한 시험 브라우저

안전한 시험 브라우저

안전한 시험 브라우저는 온라인 시험을 안전하게 치르기 위한 보안 브라우저 환경입니다. 이 소프트웨어는 모든 컴퓨터를 안전한 워크스테이션으로 바꿔줍니다. 이는 모든 유틸리티에 대한 액세스를 제어하고 학생들이 승인되지 않은 리소스를 사용하는 것을 방지합니다.

MinGW - Windows용 미니멀리스트 GNU

MinGW - Windows용 미니멀리스트 GNU

이 프로젝트는 osdn.net/projects/mingw로 마이그레이션되는 중입니다. 계속해서 그곳에서 우리를 팔로우할 수 있습니다. MinGW: GCC(GNU Compiler Collection)의 기본 Windows 포트로, 기본 Windows 애플리케이션을 구축하기 위한 무료 배포 가능 가져오기 라이브러리 및 헤더 파일로 C99 기능을 지원하는 MSVC 런타임에 대한 확장이 포함되어 있습니다. 모든 MinGW 소프트웨어는 64비트 Windows 플랫폼에서 실행될 수 있습니다.