123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- // pages/sorting/choice.js
- const app=getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- mainActiveIndex: 0,
- activeId: null,
- items:[],
- right1:"",
- wnumber:"",
- keyword:""
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData({
- wnumber:options.wnumber
- })
- this.getcaless();
- },
- onClickNav({ detail = {} }) {
- var id = detail.index || 0;
- this.setData({
- right1: this.data.right2[id]
- })
-
- },
-
- onClickItem(e) {
- var id=e.target.dataset.id;
- var title=e.currentTarget.dataset.title
- console.log(e);
- let pages = getCurrentPages();
- let prevPage = pages[pages.length - 2]; //上一页 -1为当前页面
- prevPage.setData({
- id: id,
- title:title,
- wnumber:this.data.wnumber
- })
- wx.navigateBack({
- delta: 1 //想要返回的层级
- })
-
- },
- toEnter(){
- wx.navigateTo({
- url: '../enter/enter',
- })
- },
- bindinput(e){
- console.log(e)
- this.setData({
- keyword:e.detail.value
- })
- },
-
- delete(){
- },
- getcaless: function (e) {
- console.log(e)
- //var name = e.detail.value['search - input'] ? e.detail.value['search - input'] : e.detail.value;
- var that=this;
- app.api.useApi(app.globalData.baseAppUrl + "api/admin/sorting/category", {
- keyword:this.data.keyword,
- }, "get").then(function (res) {
- console.log(res);
- if (res.code != 200) {
- wx.showLoading({
- title:res.message.msg,
- })
- setTimeout(function () {
- wx.hideLoading();
- }, 1000);
-
- } else {
- wx.hideLoading();
- var data = res.message.data;
- var shop = [];
- if(data==[] || data==""){
- wx.showLoading({
- title:"未获取到结果。",
- })
- setTimeout(function () {
- wx.hideLoading();
- }, 2000);
-
- }
- for (var index in data) {
- shop[index] = data[index].children
- }
- that.setData({
- items:data,
- right1: data[0].children,
- right2: shop
- })
- }
-
-
-
- }).catch(function (err) {
-
- console.log(222);
- })
- },
- afterRead(event) {
- const { file } = event.detail;
- // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
- wx.uploadFile({
- url: 'https://example.weixin.qq.com/upload', // 仅为示例,非真实的接口地址
- filePath: file.url,
- name: 'file',
- formData: { user: 'test' },
- success(res) {
- // 上传完成需要更新 fileList
- const { fileList = [] } = this.data;
- fileList.push({ ...file, url: res.data });
- this.setData({ fileList });
- },
- });
- },
- })
|