123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- // pages/append/append.js
- const { getCategoryAPI, upLoadGoods } = require('../../API/appraise')
- const { upLoad, chooseImage } = require('../../utils/util')
- import Toast from '@vant/weapp/toast/toast'
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- latitude: 0,
- longtitude: 0,
- mapName: "",
- columns: [],
- id: [],
- popShow: false,
- clssify: [],
- valueKeyName: "",
- index: 0,
- fileImg: [],
- // 页面数据们
- title: "",
- desc: "",
- price: 0,
- address: "",
- fileList: [],
- gid: Number,
- maxgoodsURL: 6
- },
- popChange() {
- this.setData({
- popShow: true
- })
- this.getClassifyList()
- },
- onConfirm(e) {
- const { value, index} = e.detail;
- this.setData({
- popShow: false,
- valueKeyName: value,
- index: index
- })
- },
- onCancel() {
- this.setData({
- popShow: false,
- valueKeyName: ""
- })
- },
- titleInput(e) {
- const {value, cursor, keyCode} = e.detail;
- this.setData({
- title: value
- })
- },
- describeInput(e) {
- const {value, cursor, keyCode} = e.detail;
- this.setData({
- desc: value
- })
- },
- numInput(e){
- const {value, cursor, keyCode} = e.detail;
- this.setData({
- price: parseInt(value)
- })
- },
- adressInput(e) {
- const { value, cursor, keyCode} = e.detail;
- this.setData({
- address: value
- })
- },
- upData(){
- this.setData({
- gid: this.data.id[this.data.index]
- })
- upLoadGoods(this.data).then((res) => {
- console.log(res);
- Toast({
- message: '发布商品成功!'
- })
- }).catch((err) => {
- console.log(err);
- })
- console.log(this.data);
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- },
- getClassifyList() {
- getCategoryAPI(this.data)
- .then((res) => {
- const { code, data, mesage } = res.data;
- const name = [];
- const id = [];
- for (let i = 0; i < data.length; i++) {
- name[i] = data[i].Name;
- id[i] = data[i].Id;
- }
- console.log(id);
- this.setData({
- columns: name,
- id: id
- })
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- },
- afterRead(e) {
- const { file } = e.detail;
- upLoad(file.url).then((res) => {
- console.log(res);
- const { fileList = [], fileImg = [] } = this.data;
- fileImg.push({ ...file, url: res.Url });
- fileList.push(res.Url)
- this.setData({
- fileList,
- fileImg
- })
- console.log(this.data.fileList);
- })
- }
- })
|