|
作者:JoyJin,來(lái)自授權(quán)地址
地圖用的是百度的地圖,鏈接:http://lbsyun.baidu.com/index.php?title=wxjsapi/guide/getlocation
獲取日期時(shí)間可以用小程序里自帶的js文件,var util = require('../../utils/util.js') 引入文件
-
var date = new Date(); //有需要改的參數(shù)可以自己定義也可以去源文件找到然后更改
-
//傳后臺(tái)用這個(gè)參數(shù)
-
var paramTime = util.formatTime2(date);
-
var dateTime = util.formatDate(date);
-
var time = util.formatTime3(date);
-
that.setData({
-
paramTime: paramTime,
-
dateTime: dateTime,
-
time: time,
-
type: type
-
})
圖片上傳:
-
//點(diǎn)擊上傳圖片
-
bindTabTap: function () {
-
var that = this
-
var tokend = wx.getStorageSync('tokend')
-
var indexId = wx.getStorageSync('indexId')
-
wx.chooseImage({
-
count: 1, // 默認(rèn)9
-
sizeType: ['compressed'], //壓縮圖
-
sourceType: ['album'], //相冊(cè)
-
success: function (res) {
-
// 返回選定照片的本地文件路徑列表,tempFilePath可以作為img標(biāo)簽的src屬性顯示圖片
-
var tempFilePaths = res.tempFilePaths
-
wx.uploadFile({
-
url: 'https://..../' + indexId + '/....?token=' + tokend, //接口地址
-
filePath: tempFilePaths[0], //要上傳文件資源的路徑
-
name: 'pic', //文件對(duì)應(yīng)的 key , 開發(fā)者在服務(wù)器端通過(guò)這個(gè) key 可以獲取到文件二進(jìn)制內(nèi)容
-
header: { 'content-type': 'multipart/form-data' }, //客戶端發(fā)起一個(gè) HTTPS POST 請(qǐng)求,其中 content-type 為 multipart/form-data HTTP 請(qǐng)求 Header , header 中不能設(shè)置 Referer
-
formData: { //HTTP 請(qǐng)求中其他額外的 form data
-
'type': that.data.type,
-
'time': that.data.paramTime,
-
'site': that.data.address
-
},
-
success: function (res) { //接口調(diào)用成功的回調(diào)函數(shù)
-
var data = res.data //開發(fā)者服務(wù)器返回的數(shù)據(jù)
-
wx.redirectTo({ //關(guān)閉當(dāng)前頁(yè)面,跳轉(zhuǎn)到應(yīng)用內(nèi)的某個(gè)頁(yè)面。
-
url: '../....', //需要跳轉(zhuǎn)的應(yīng)用內(nèi)非 tabBar 的頁(yè)面的路徑,路徑后可以帶參數(shù)。參數(shù)與路徑之間使用?分隔,參數(shù)鍵與參數(shù)值用=相連,不同參數(shù)用&分隔;如 'path?key=value&key2=value2'
-
success: function (res) {
-
wx.showToast({
-
title: '簽到成功~',
-
image:'../Image/suess.png',
-
duration: 2000
-
})
-
},
-
})
-
},
-
fail: function (res) { //接口調(diào)用失敗的回調(diào)函數(shù)
-
console.log('error' + ':' + res)
-
}
-
})
-
}
-
})
-
},
Bug & Tip
tip: 最大并發(fā)限制是 10 個(gè) tip: 默認(rèn)超時(shí)時(shí)間和最大超時(shí)時(shí)間都是 60s
|