作者 liaolinfeng

测试提交

//app.js
App({
post(url, data, headerParams) {
/**
* 自定义post函数,返回Promise
* +-------------------
* @param {String} url 接口网址
* @param {arrayObject} data 要传的数组对象 like: {name: 'name', age: 32}
* +-------------------
* @return {Promise} promise 返回promise供后续操作
*/
wx.showNavigationBarLoading()
wx.showLoading({
title: '加载中',
})
var promise = new Promise((resolve, reject) => {
let that = this;
let postData = data;
let baseurl = 'https://soochow.w.broteam.cn/api/';//仅为实例地址
let header = Object.assign({ 'content-type': 'application/x-www-form-urlencoded' }, headerParams)
//发起网络请求
wx.request({
url: baseurl + url,
data: postData,
method: 'POST',
header: header ,
success: function (res) {//返回取得的数据
if (res.data.code == '10001'){
wx.clearStorageSync()
wx.showModal({
title: '提示',
content: res.data.msg,
showCancel: false,
success: function(res){
wx.redirectTo({
url: '/pages/start/start',
})
}
})
return false
}else{
resolve(res.data);
}
setTimeout(function () {
wx.hideLoading()
}, 600)
wx.hideNavigationBarLoading()
},
error: function (e) {
reject("网络错误");
wx.hideLoading();
wx.hideNavigationBarLoading();
wx.showModal({
title: '提示',
content: res.data.msg,
showCancel: false
})
}
})
})
wx.hideLoading();
return promise;
},
onLaunch: function () {
// 展示本地存储能力
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
// 登录
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
}
})
// 获取用户信息
wx.getSetting({
success: res => {
if (res.authSetting['scope.userInfo']) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
wx.getUserInfo({
success: res => {
// 可以将 res 发送给后台解码出 unionId
this.globalData.userInfo = res.userInfo
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
if (this.userInfoReadyCallback) {
this.userInfoReadyCallback(res)
}
}
})
}
}
})
},
globalData: {
userInfo: null
}
})
\ No newline at end of file
... ...
{
"pages": [
"pages/start/start",
"pages/chooseadress/chooseadress",
"pages/share_record/share_record",
"pages/index/index",
"pages/poster/poster",
"pages/record/record",
"pages/share_code/share_code"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle": "black"
}
}
\ No newline at end of file
... ...
/**app.wxss**/
page{
width:100%;
height:100%;
overflow: hidden;
}
.container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 200rpx 0;
box-sizing: border-box;
}
... ...
function AMapWX(a){this.key=a.key,this.requestConfig={key:a.key,s:"rsx",platform:"WXJS",appname:a.key,sdkversion:"1.2.0",logversion:"2.0"}}AMapWX.prototype.getWxLocation=function(a,b){wx.getLocation({type:"gcj02",success:function(a){var c=a.longitude+","+a.latitude;wx.setStorage({key:"userLocation",data:c}),b(c)},fail:function(c){wx.getStorage({key:"userLocation",success:function(a){a.data&&b(a.data)}}),a.fail({errCode:"0",errMsg:c.errMsg||""})}})},AMapWX.prototype.getRegeo=function(a){function c(c){var d=b.requestConfig;wx.request({url:"https://restapi.amap.com/v3/geocode/regeo",data:{key:b.key,location:c,extensions:"all",s:d.s,platform:d.platform,appname:b.key,sdkversion:d.sdkversion,logversion:d.logversion},method:"GET",header:{"content-type":"application/json"},success:function(b){var d,e,f,g,h,i,j,k,l;b.data.status&&"1"==b.data.status?(d=b.data.regeocode,e=d.addressComponent,f=[],g="",d&&d.roads[0]&&d.roads[0].name&&(g=d.roads[0].name+"附近"),h=c.split(",")[0],i=c.split(",")[1],d.pois&&d.pois[0]&&(g=d.pois[0].name+"附近",j=d.pois[0].location,j&&(h=parseFloat(j.split(",")[0]),i=parseFloat(j.split(",")[1]))),e.provice&&f.push(e.provice),e.city&&f.push(e.city),e.district&&f.push(e.district),e.streetNumber&&e.streetNumber.street&&e.streetNumber.number?(f.push(e.streetNumber.street),f.push(e.streetNumber.number)):(k="",d&&d.roads[0]&&d.roads[0].name&&(k=d.roads[0].name),f.push(k)),f=f.join(""),l=[{iconPath:a.iconPath,width:a.iconWidth,height:a.iconHeight,name:f,desc:g,longitude:h,latitude:i,id:0,regeocodeData:d}],a.success(l)):a.fail({errCode:b.data.infocode,errMsg:b.data.info})},fail:function(b){a.fail({errCode:"0",errMsg:b.errMsg||""})}})}var b=this;a.location?c(a.location):b.getWxLocation(a,function(a){c(a)})},AMapWX.prototype.getWeather=function(a){function d(d){var e="base";a.type&&"forecast"==a.type&&(e="all"),wx.request({url:"https://restapi.amap.com/v3/weather/weatherInfo",data:{key:b.key,city:d,extensions:e,s:c.s,platform:c.platform,appname:b.key,sdkversion:c.sdkversion,logversion:c.logversion},method:"GET",header:{"content-type":"application/json"},success:function(b){function c(a){var b={city:{text:"城市",data:a.city},weather:{text:"天气",data:a.weather},temperature:{text:"温度",data:a.temperature},winddirection:{text:"风向",data:a.winddirection+"风"},windpower:{text:"风力",data:a.windpower+"级"},humidity:{text:"湿度",data:a.humidity+"%"}};return b}var d,e;b.data.status&&"1"==b.data.status?b.data.lives?(d=b.data.lives,d&&d.length>0&&(d=d[0],e=c(d),e["liveData"]=d,a.success(e))):b.data.forecasts&&b.data.forecasts[0]&&a.success({forecast:b.data.forecasts[0]}):a.fail({errCode:b.data.infocode,errMsg:b.data.info})},fail:function(b){a.fail({errCode:"0",errMsg:b.errMsg||""})}})}function e(e){wx.request({url:"https://restapi.amap.com/v3/geocode/regeo",data:{key:b.key,location:e,extensions:"all",s:c.s,platform:c.platform,appname:b.key,sdkversion:c.sdkversion,logversion:c.logversion},method:"GET",header:{"content-type":"application/json"},success:function(b){var c,e;b.data.status&&"1"==b.data.status?(e=b.data.regeocode,e.addressComponent?c=e.addressComponent.adcode:e.aois&&e.aois.length>0&&(c=e.aois[0].adcode),d(c)):a.fail({errCode:b.data.infocode,errMsg:b.data.info})},fail:function(b){a.fail({errCode:"0",errMsg:b.errMsg||""})}})}var b=this,c=b.requestConfig;a.city?d(a.city):b.getWxLocation(a,function(a){e(a)})},AMapWX.prototype.getPoiAround=function(a){function d(d){var e={key:b.key,location:d,s:c.s,platform:c.platform,appname:b.key,sdkversion:c.sdkversion,logversion:c.logversion};a.querytypes&&(e["types"]=a.querytypes),a.querykeywords&&(e["keywords"]=a.querykeywords),wx.request({url:"https://restapi.amap.com/v3/place/around",data:e,method:"GET",header:{"content-type":"application/json"},success:function(b){var c,d,e,f;if(b.data.status&&"1"==b.data.status){if(b=b.data,b&&b.pois){for(c=[],d=0;d<b.pois.length;d++)e=0==d?a.iconPathSelected:a.iconPath,c.push({latitude:parseFloat(b.pois[d].location.split(",")[1]),longitude:parseFloat(b.pois[d].location.split(",")[0]),iconPath:e,width:22,height:32,id:d,name:b.pois[d].name,address:b.pois[d].address});f={markers:c,poisData:b.pois},a.success(f)}}else a.fail({errCode:b.data.infocode,errMsg:b.data.info})},fail:function(b){a.fail({errCode:"0",errMsg:b.errMsg||""})}})}var b=this,c=b.requestConfig;a.location?d(a.location):b.getWxLocation(a,function(a){d(a)})},AMapWX.prototype.getStaticmap=function(a){function f(b){c.push("location="+b),a.zoom&&c.push("zoom="+a.zoom),a.size&&c.push("size="+a.size),a.scale&&c.push("scale="+a.scale),a.markers&&c.push("markers="+a.markers),a.labels&&c.push("labels="+a.labels),a.paths&&c.push("paths="+a.paths),a.traffic&&c.push("traffic="+a.traffic);var e=d+c.join("&");a.success({url:e})}var e,b=this,c=[],d="https://restapi.amap.com/v3/staticmap?";c.push("key="+b.key),e=b.requestConfig,c.push("s="+e.s),c.push("platform="+e.platform),c.push("appname="+e.appname),c.push("sdkversion="+e.sdkversion),c.push("logversion="+e.logversion),a.location?f(a.location):b.getWxLocation(a,function(a){f(a)})},AMapWX.prototype.getInputtips=function(a){var b=this,c=b.requestConfig,d={key:b.key,s:c.s,platform:c.platform,appname:b.key,sdkversion:c.sdkversion,logversion:c.logversion};a.location&&(d["location"]=a.location),a.keywords&&(d["keywords"]=a.keywords),a.type&&(d["type"]=a.type),a.city&&(d["city"]=a.city),a.citylimit&&(d["citylimit"]=a.citylimit),wx.request({url:"https://restapi.amap.com/v3/assistant/inputtips",data:d,method:"GET",header:{"content-type":"application/json"},success:function(b){b&&b.data&&b.data.tips&&a.success({tips:b.data.tips})},fail:function(b){a.fail({errCode:"0",errMsg:b.errMsg||""})}})},AMapWX.prototype.getDrivingRoute=function(a){var b=this,c=b.requestConfig,d={key:b.key,s:c.s,platform:c.platform,appname:b.key,sdkversion:c.sdkversion,logversion:c.logversion};a.origin&&(d["origin"]=a.origin),a.destination&&(d["destination"]=a.destination),a.strategy&&(d["strategy"]=a.strategy),a.waypoints&&(d["waypoints"]=a.waypoints),a.avoidpolygons&&(d["avoidpolygons"]=a.avoidpolygons),a.avoidroad&&(d["avoidroad"]=a.avoidroad),wx.request({url:"https://restapi.amap.com/v3/direction/driving",data:d,method:"GET",header:{"content-type":"application/json"},success:function(b){b&&b.data&&b.data.route&&a.success({paths:b.data.route.paths,taxi_cost:b.data.route.taxi_cost||""})},fail:function(b){a.fail({errCode:"0",errMsg:b.errMsg||""})}})},AMapWX.prototype.getWalkingRoute=function(a){var b=this,c=b.requestConfig,d={key:b.key,s:c.s,platform:c.platform,appname:b.key,sdkversion:c.sdkversion,logversion:c.logversion};a.origin&&(d["origin"]=a.origin),a.destination&&(d["destination"]=a.destination),wx.request({url:"https://restapi.amap.com/v3/direction/walking",data:d,method:"GET",header:{"content-type":"application/json"},success:function(b){b&&b.data&&b.data.route&&a.success({paths:b.data.route.paths})},fail:function(b){a.fail({errCode:"0",errMsg:b.errMsg||""})}})},AMapWX.prototype.getTransitRoute=function(a){var b=this,c=b.requestConfig,d={key:b.key,s:c.s,platform:c.platform,appname:b.key,sdkversion:c.sdkversion,logversion:c.logversion};a.origin&&(d["origin"]=a.origin),a.destination&&(d["destination"]=a.destination),a.strategy&&(d["strategy"]=a.strategy),a.city&&(d["city"]=a.city),a.cityd&&(d["cityd"]=a.cityd),wx.request({url:"https://restapi.amap.com/v3/direction/transit/integrated",data:d,method:"GET",header:{"content-type":"application/json"},success:function(b){if(b&&b.data&&b.data.route){var c=b.data.route;a.success({distance:c.distance||"",taxi_cost:c.taxi_cost||"",transits:c.transits})}},fail:function(b){a.fail({errCode:"0",errMsg:b.errMsg||""})}})},AMapWX.prototype.getRidingRoute=function(a){var b=this,c=b.requestConfig,d={key:b.key,s:c.s,platform:c.platform,appname:b.key,sdkversion:c.sdkversion,logversion:c.logversion};a.origin&&(d["origin"]=a.origin),a.destination&&(d["destination"]=a.destination),wx.request({url:"https://restapi.amap.com/v4/direction/bicycling",data:d,method:"GET",header:{"content-type":"application/json"},success:function(b){b&&b.data&&b.data.data&&a.success({paths:b.data.data.paths})},fail:function(b){a.fail({errCode:"0",errMsg:b.errMsg||""})}})},module.exports.AMapWX=AMapWX;
\ No newline at end of file
... ...
var config = {
key: '856d7698b954d8c2356bce3a3be86f1d'
}
module.exports.Config = config;
\ No newline at end of file
... ...
const app= getApp();
var amapFile = require('../../libs/amap-wx.js');
var config = require('../../libs/config.js');
Page({
/**
* 页面的初始数据
*/
data: {
showright: true,
showbtn: true,
showitem:false,
chooseitem: [],
cityList: [],
currentindex: 0 ,//当前index
//地图部分的数据
staticsrc:'',//生成的静态图
markers: [],
latitude: '',//当前维度
longitude: '',//当前经度
textData: {},//
city: '',
tips: '',//input输入选项
scale: '12',
width:'50',
height: '40',
iconPathSelected: '../../images/yy.png',
iconPath: '../../images/dingwei_no.png'
},
chooseone(e) {
let that = this;
let index = e.currentTarget.dataset.index;
let cityList = that.data.cityList;
let showright = that.data.showright;
if (cityList[index].name=='自定义'){
showright=false;
}else{
showright = true;
}
for (let i in cityList){
if (i == index){
cityList[i].parentcheck = true;
}else{
cityList[i].parentcheck = false;
}
}
that.setData({
cityList: cityList,
showright: showright,
currentindex:index
})
},
choosetwo(e){
let that=this;
let cityList = that.data.cityList;
let index = e.currentTarget.dataset.index;
let currentindex = that.data.currentindex;
cityList[currentindex].children[index].check = !cityList[currentindex].children[index].check;
for (let obj of cityList){
let num = obj.num;
if (obj.parentcheck){
num=0
for (let item of obj.children){
if (item.check){
num++;
}
}
}
obj.num=num;
}
that.setData({
cityList: cityList
})
},
//输入关键词并获取周围位置提示
setkeyword(e){
let that=this;
var keywords = e.detail.value;
if (keywords==''){
that.setData({
tips: ''
});
}else{
var key = config.Config.key;
var myAmapFun = new amapFile.AMapWX({ key: key });
myAmapFun.getInputtips({
keywords: keywords,
location: that.data.lonlat,
city: that.data.city,
success: function (data) {
if (data && data.tips) {
let newtips = [];
for (let obj of data.tips) {
if (obj.location != undefined && obj.location != '') {//把没有坐标的地址删掉
newtips.push(obj)
}
}
that.setData({
tips: newtips,
});
}
}
})
}
},
//设置关键词
choosekeyword(e){
let that=this;
that.setData({
keywords: e.currentTarget.dataset.keywords
})
if (that.data.keywords.length >0){
let location = e.currentTarget.dataset.location.split(',')
let tempMark = [{
id: '0',
name: e.currentTarget.dataset.keywords,
latitude: location[1],//纬度
longitude: location[0],//经度
iconPath: this.data.iconPath,
width: this.data.width,
height: this.data.height
}]
that.setData({
markers: tempMark,
latitude: location[1],//纬度
longitude: location[0],//经度
tips: '',
scale: '13'
})
}else{
that.setData({
tips: ''
})
}
},
//刚刚开始拿到地图
getMap(){
var that = this;
var key = config.Config.key;
var myAmapFun = new amapFile.AMapWX({ key: key});
myAmapFun.getRegeo({
iconPathSelected: '../../images/yy.png',
iconPath: "../../images/dingwei_no.png",
iconWidth: 50,
iconHeight: 40,
location:'120.5544751,31.34876492',//中心点苏州市姑苏区
success: function (data) {
that.setData({
latitude: data[0].latitude,
longitude: data[0].longitude,
city: data[0].regeocodeData.addressComponent.city
});
},
fail: function (info) {
}
})
},
//根据坐标找到地图
mapkey(location){
var that = this;
that.setData({
tips:''
})
var key = config.Config.key;
var myAmapFun = new amapFile.AMapWX({ key: key });
var params = {
iconPathSelected: '../../images/yy.png',
iconPath: '../../images/dingwei_no.png',
success: function (data) {
let markersData = data.markers;
var poisData = data.poisData;
var markers_new = [];
markersData.forEach(function (item, index) {
markers_new.push({
id: item.id,
latitude: item.latitude,
longitude: item.longitude,
iconPath: item.iconPath,
width: item.width,
height: item.height
})
})
if (poisData.length > 0) {
let chooseitem = that.data.chooseitem;
chooseitem.push(poisData[0]);
that.setData({
markers: markers_new,
city: poisData[0].cityname || '',
latitude: markersData[0].latitude,//维度,
longitude: markersData[0].longitude , //经度,
chooseitem: chooseitem
});
} else {
wx.getLocation({
type: 'gcj02',
success: function (res) {
that.setData({
latitude: res.latitude
});
that.setData({
longitude: res.longitude
});
that.setData({
city: '苏州市'
});
},
fail: function () {
that.setData({
latitude: 31.32416
});
that.setData({
longitude: 120.629029
});
that.setData({
city: '苏州市'
});
}
})
}
},
fail: function (info) {
}
}
params.location = location;
params.querykeywords=that.data.city
myAmapFun.getPoiAround(params)
},
delchooseitem(e){
let that=this;
let cityList = that.data.cityList;
let chooseitem = that.data.chooseitem;
chooseitem.splice(parseInt(e.currentTarget.dataset.index),1);
cityList[cityList.length - 1].num = chooseitem.length;
that.setData({
chooseitem: chooseitem,
cityList: cityList
})
},
//获取景点信息
getdata(){
let that=this;
let url ='home/home/index';
console.log(wx.getStorageSync('token'))
let header={
'XX-Token': wx.getStorageSync('token')
}
app.post(url, {}, header).then((res)=>{
let cityList = [];
let currentlist=[];
let j=0;
for(let i in res){
if(res[i].length>0){
for (let j in res[i]) {
res[i][j].check = false;
}
let tem = {
id: j,
num: 0,
name: i,
parentcheck: false,
children: res[i]
};
if (j == 0) {
currentlist = res[i];
tem.parentcheck = true;
}
j++;
cityList.push(tem)
}
}
let t={
id:j+1,
num: 0,
name: '自定义',
parentcheck: false,
children: []
}
cityList.push(t);
that.setData({
cityList: cityList,
currentlist: currentlist
})
}).catch((errMsg)=>{
console.log(errMsg)
})
},
makertap(e){
console.log(e)
var that = this;
var id = e.markerId;
let markersData = this.data.markers
let chooseitem = this.data.chooseitem
let cityList = this.data.cityList
let choose
if(chooseitem.length>0){
for (let obj of chooseitem) {
if (obj.name == markersData[0].name) {
choose = false
return false
} else {
choose = true
}
}
if (choose) {
chooseitem.push(markersData[0])
cityList[cityList.length - 1].num = chooseitem.length
this.setData({
chooseitem: chooseitem,
cityList: cityList
})
}
}else{
chooseitem.push(markersData[0])
cityList[cityList.length - 1].num = chooseitem.length
this.setData({
chooseitem: chooseitem,
cityList: cityList
})
}
},
changeMarkerColor: function (data, i) {
var that = this;
var markers = [];
for (var j = 0; j < data.length; j++) {
if (j == i) {
data[j].iconPath = "../../img/marker_checked.png";
} else {
data[j].iconPath = "../../img/marker.png";
}
markers.push({
id: data[j].id,
latitude: data[j].latitude,
longitude: data[j].longitude,
iconPath: data[j].iconPath,
width: data[j].width,
height: data[j].height
})
}
that.setData({
markers: markers
});
},
showMarkerInfo: function (data, i) {
var that = this;
let chooseitem = that.data.chooseitem;
that.setData({
textData: {
name: data[i].name,
desc: data[i].address
}
});
},
//生成静态地图
getStaticmap(markers) {
var that = this;
var key = config.Config.key;
var myAmapFun = new amapFile.AMapWX({ key: key });
wx.getSystemInfo({
success: function (data) {
var height = 400;
var width = 600;
var size = width + "*" + height;
myAmapFun.getStaticmap({
zoom: 8,
size: size,
scale: 2,
location: "120.629029,31.32416",//中心点苏州拙政园
markers: markers,
success: function (data) {
wx.setStorageSync('staticsrc', data.url)
that.setData({
staticsrc: data.url
})
},
fail: function (info) {
}
})
}
})
},
//生成音乐LOGo
gorecord(){
let that=this;
let cityList = that.data.cityList;
let chooseitem = that.data.chooseitem;
let staticmarkers = "-1,http://omzkju13s.bkt.clouddn.com/Aknvs.png,0:120.635512,31.32853";
let locationurl='';
let tempLocation = []
for (let obj of cityList){
for (let item of obj.children){
if (item.check){
tempLocation.push(item.coordinate)
// if(locationurl==''){
// locationurl = item.coordinate;
// }else{
locationurl += '|' + item.coordinate;
// }
staticmarkers += (';'+ item.coordinate);
}
}
}
if(chooseitem.length>0){
for(let obj of chooseitem){
let tempLocation = obj.longitude +','+ obj.latitude
locationurl += '|'+tempLocation
}
}
that.getStaticmap(staticmarkers)//调用静态图生成方法,生成图片
if (locationurl.length==0){
wx.showToast({
title: '请选择地址',
icon: 'none',
duration: 2000,
})
}else{
let url ='home/home/create';
let header = {
'XX-Token': wx.getStorageSync('token')
}
let params={
coordinate: locationurl,
file: that.data.staticsrc,
token: wx.getStorageSync('token')
}
app.post(url, params, header).then((res)=>{
console.log(res.code)
if(res.code==20000){
wx.navigateTo({
url: '../record/record?poster_id=' + res.poster_id,
success: function (res) { },
fail: function (res) { },
complete: function (res) { },
})
}
}).catch((errMsg)=>{
wx.showModal({
title: '提示',
content: errMsg.msg,
showCancel: false
})
console.log(errMsg)
})
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
let that=this;
that.getdata();
that.getMap();
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
}
})
\ No newline at end of file
... ...
{
"navigationBarTitleText": "踏趣苏州",
"navigationBarBackgroundColor": "#fff"
}
\ No newline at end of file
... ...
<!--pages/chooseadress/chooseadress.wxml-->
<view class='bg'>
<image src='../../images/bg@2x.jpg'></image>
<image src='{{src}}'></image>
<view class='top_text'>必选地点</view>
<view class='main'>
<view class='main_left'>
<view class="left_cell {{item.parentcheck?'activity_cell':''}}" wx:for='{{cityList}}' wx:key bindtap='chooseone' data-index='{{index}}'>
<view class='unit_num' wx:if='{{item.num != 0}}'>{{item.num}}</view>
<text>{{item.name}}</text>
</view>
</view>
<view class="main_rigth {{showright?'heiht80':''}}" wx:if='{{showright}}'>
<view class="rigth_cell {{item.check?'activity_cell':''}}" wx:for='{{cityList[currentindex].children}}' data-index='{{index}}' wx:key bindtap='choosetwo'>{{item.scenic_name}}</view>
</view>
<view class="main_rigth {{showright?'':'heiht100'}}" wx:else>
<view class='seach_box'>
<view class='seach_text'>
<input placeholder='请输入地点' bindinput='setkeyword'
value='{{keywords}}' placeholder-class='pclass'></input>
</view>
<cover-view class='seach_items' wx:if='{{tips.length !=0 }}'>
<cover-view class='seach_item' wx:for='{{tips}}' wx:key data-keywords='{{item.name}} ' data-location='{{item.location}}' bindtap='choosekeyword'>
<cover-view>{{item.name}}</cover-view>
</cover-view>
</cover-view>
</view>
<view class='map_box'>
<view class='map_container'>
<map class="map" id="map" longitude="{{longitude}}" latitude="{{latitude}}" show-location="true" scale="{{scale}}" markers="{{markers}}" bindmarkertap="makertap"></map>
</view>
</view>
<view class='tab_box' wx:if='{{chooseitem.length!=0}}'>
<view class='tab_cell' wx:for='{{chooseitem}}' wx:key style='order:{{chooseitem.length-index}}'>
<view class='close_box' catchtap='delchooseitem' data-index='{{index}}'>
<image src='../../images/close2.png'></image>
</view>
<text>{{item.name}}</text>
</view>
</view>
</view>
</view>
<view class='bottom_btn' wx:if='{{showbtn}}' bindtap='gorecord'>生成我的音乐LOGO</view>
</view>
... ...
/* pages/chooseadress/chooseadress.wxss */
page{
width: 100%;
height: 100%;
overflow: hidden
}
.map_container{
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
.bg{
position: fixed;
top:0;
left:0;
right: 0;
bottom:0;
width:100%;
height: 100%;
}
.bg image{
width:100%;
height: 100%;
}
.top_text{
position: absolute;
color:#222;
font-size:40rpx;
top:4%;
left:50%;
transform: translateX(-50%);
font-weight: bold;
}
.main{
position: absolute;
top:15%;
height: 80%;
width:100%;
padding:0 0 0 30rpx;
color:#D85372;
font-size:30rpx;
display: flex;
}
.main_left{
height: 80%;
overflow-y: auto;
overflow-x: hidden;
margin:0 20rpx 0 0;
}
.left_cell{
position: relative;
padding:0 10rpx;
width:125rpx;
height: 88rpx;
overflow-x: auto;
text-align:left;
display: flex;
align-items: center;
white-space: nowrap;
border:1rpx solid #D85372;
border-radius: 10rpx;
margin:0 0 24rpx 0;
}
.unit_num{
position: absolute;
width:32rpx;
height: 32rpx;
border-radius: 50%;
top:8rpx;
right:5rpx;
background-color: #FFC426;
font-size:26rpx;
color:#222222;
display: flex;
justify-content: center;
align-items: center;
z-index:5;
}
.main_rigth{
width:560rpx;
height: 80%;
overflow-x: hidden;
overflow-y: auto;
}
.heiht80{
height: 80%;
}
.heiht100{
height: 100%;
}
.rigth_cell{
display: inline-block;
padding: 0 34rpx;
margin:0 20rpx 24rpx 0;
height: 88rpx;
line-height: 88rpx;
text-align: center;
border-radius: 10rpx;
border:1rpx solid #D85372;
}
.seach_box{
width:530rpx;
box-sizing: border-box;
position:relative;
}
.seach_items{
background-color: #fff;
position: absolute;
top:88rpx;
width:530rpx;
border-radius: 10rpx;
padding:0 30rpx;
box-sizing: border-box;
z-index:100;
height: 600rpx;
overflow-y: scroll;
}
.seach_item{
padding:25rpx 0;
display: flex;
justify-content: space-between;
align-items: center;
color:#D85372;
font-size:30rpx;
border-bottom: 1rpx #ccc dashed;
}
.seach_item:last-child{
border:none;
}
.icon_img{
width:13rpx;
height:22rpx;
}
.icon_img image{
display: block;
width:100%;
height: 100%;
}
.seach_text{
height: 88rpx;
width:100%;
box-sizing: border-box;
overflow: hidden;
border-radius: 10rpx;
border:1rpx solid #D85372;
margin:0 30rpx 0 0;
}
.seach_text input{
box-sizing: border-box;
padding:0 30rpx;
width:100%;
height: 100%;
color:#D85372;
font-size:30rpx;
}
.pclass{
color:#D85372;
}
.map_box{
position: relative;
margin:24rpx 0 0 0;
width:530rpx;
height: 528rpx;
overflow: hidden;
}
.tab_box{
width:100%;
padding:10rpx 0 0 0;
box-sizing: border-box;
height: 210rpx;
overflow-y: auto;
margin:60rpx 0 0 0;
display: flex;
flex-wrap: wrap;
}
.tab_cell{
position: relative;
display: flex;
justify-content: center;
align-items: center;
color:#fff;
font-weight: bold;
background-color: #DB214C;
border-radius: 10rpx;
height: 88rpx;
padding:0 30rpx;
margin: 0 30rpx 20rpx 0;
}
.close_box{
position:absolute;
top:-8rpx;
right:-9rpx;
width:32rpx;
height:32rpx;
border-radius:50%;
overflow:hidden;
background-color: #fff;
}
.close_box image{
width:100%;
height: 100%;
}
.bottom_btn{
position: absolute;
display: flex;
align-items: center;
justify-content: center;
background-color: #007CC2;
bottom:0;
height: 88rpx;
width:100%;
color:#fff;
font-size:32rpx;
}
.activity_cell{
background-color:#DB214C;
color:#fff;
font-weight: bold;
}
.map_container map{
width:100%;
height: 100%;
}
.map_text{
position: absolute;
left: 0;
right: 0;
bottom: 0px;
height: 80px;
background: #fff;
padding: 0 15px;
}
text{
margin: 5px 0;
display: block;
font-size:12px;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
\ No newline at end of file
... ...
//index.js
//获取应用实例
const app = getApp()
Page({
data: {
list:[{
id:0,
}]
},
gochoose(){
wx.navigateTo({
url: '../chooseadress/chooseadress',
success: function(res) {},
fail: function(res) {},
complete: function(res) {},
})
},
onLoad: function () {
},
})
... ...
{
"navigationBarTitleText": "踏趣苏州",
"navigationBarBackgroundColor": "#fff"
}
... ...
<view class='bg'>
<image src='../../images/bg@2x.jpg'></image>
<view class='top_text'>
<view class='mini_title'>去过的地方,就是连接起来的一段脚步音符</view>
<view class='title'>来制作你的音乐logo吧</view>
</view>
<view class='center_img'>
<image src='../../images/suzhou@2x.png'></image>
</view>
<view class='index_btn' bindtap='gochoose'>下一步</view>
</view>
\ No newline at end of file
... ...
.bg{
width:100%;
height: 100%;
position: fixed;
top:0;
bottom:0;
left:0;
}
.bg image{
width:100%;
height: 100%;
}
.top_text{
width:100%;
top:5%;
position: absolute;
color:#DB214C;
font-weight: bold;
text-align: center;
}
.mini_title{
font-size:25rpx;
margin:0 0 20rpx 0;
}
.title{
font-size:47rpx;
word-spacing: 10rpx;
}
.center_img{
position: absolute;
width:656rpx;
height: 572rpx;
z-index:2;
top:24%;
left:50%;
transform: translateX(-50%);
overflow: hidden;
}
.center_img image{
width:100%;
}
.index_btn{
position: absolute;
z-index:3;
color:#fff;
font-size:32rpx;
width:320rpx;
height: 80rpx;
line-height: 80rpx;
text-align: center;
bottom:8%;
left:50%;
transform: translateX(-50%);
background-color: #007CC2;
border-radius: 40rpx;
}
.index_btn:active{
opacity: 0.7;
}
\ No newline at end of file
... ...
// pages/poster.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{"navigationBarTitleText": "踏趣苏州"}
\ No newline at end of file
... ...
<!--pages/poster.wxml-->
<view class='bg'>
<image src='../../images/abg.png'></image>
<view class='item_box'>
<view class='item'>
<text>巴塞罗那因为高迪的建筑,拥有了自然万物的灵魂。
而我们又该如何表达苏州?巴塞罗那因为高迪的建筑,拥有了自然万物的灵魂。
而我们又该如何表达苏州?</text>
<text>巴塞罗那因为高迪的建筑,拥有了自然万物的灵魂。
而我们又该如何表达苏州?巴塞罗那因为高迪的建筑,拥有了自然万物的灵魂。
而我们又该如何表达苏州?</text>
</view>
<view class='item'>
<view class='item_title'>作品要求</view>
<view class='item_cell'>
<text class='item_left'>内容</text>
<view class='item_rigth'>你在任何的城市行旅创意作品</view>
</view>
<view class='item_cell'>
<text class='item_left'>形式</text>
<view class='item_rigth'>音频节目、原创歌曲、短视频均可。</view>
</view>
<view class='item_cell'>
<text class='item_left'>时长</text>
<view class='item_rigth'>5分钟以内。</view>
</view>
</view>
<view class='item_btn'>开始提交</view>
</view>
</view>
\ No newline at end of file
... ...
/* pages/poster.wxss */
@import "../index/index.wxss";
.item_box{
position: absolute;
top:5%;
left:50%;
transform: translateX(-50%);
width:654rpx;
}
.item{
margin:26rpx 0 0 0;
color:#542C70;
font-size:32rpx;
width:654rpx;
height: 470rpx;
overflow-y: auto;
border-radius: 15rpx;
box-sizing: border-box;
padding:60rpx 40rpx;
background-color: rgba(255,255,255,1);
}
.item_title{
color:#333;
font-size: 32rpx;
font-weight: bold;
}
.item_cell{
margin:30rpx 0;
position: relative;
color:#333;
font-size:30rpx;
padding:0 0 0 84rpx;
}
.item_left{
position: absolute;
left:0;
top:0;
display: inline-block;
margin: 0 20rpx 0 0;
padding:5rpx 8rpx;
border-radius: 5rpx;
color:#fff;
font-weight: bold;
font-size: 28rpx;
background-color: #B63556;
}
.item_rigth{
width:420rpx;
display: inline-block;
}
.item_btn{
position: absolute;
width:520rpx;
height: 88rpx;
border-radius: 44rpx;
left: 50%;
bottom:-44rpx;
transform: translateX(-50%);
color:#fff;
font-weight: bold;
font-size:34rpx;
display: flex;
justify-content: center;
align-items: center;
background: linear-gradient(to right,#952567,#D93948)
}
.item_btn:active{
opacity: 0.7
}
\ No newline at end of file
... ...
// pages/record/record.js
const app = getApp();
var amapFile = require('../../libs/amap-wx.js');
var config = require('../../libs/config.js');
var bgM = wx.createInnerAudioContext();
Page({
/**
* 页面的初始数据
*/
data: {
play:true, //true为播放,flase暂停
//地图数据
markers: [],//显示点的坐标对象
latitude: '',//当前显示的点维度
longitude: '',//当前显示点的经度
scale:'12',
src:'',
startsec:'00:00',
endsec:'00:00',
palyrate:'',//播放的百分比
poster_id:'',//海报ID
musicsrc:'',
duration:0
},
//生成静态地图
getStaticmap(markers) {
var that = this;
var key = config.Config.key;
var myAmapFun = new amapFile.AMapWX({ key: key });
wx.getSystemInfo({
success: function (data) {
var height = 300;
var width = 500;
var size = width + "*" + height;
myAmapFun.getStaticmap({
zoom: 8,
size: size,
scale: 2,
location: "120.644312,31.421561",//中心点苏州火车北站
markers: markers,
success: function (data) {
that.setData({
staticsrc: data.url
})
},
fail: function (info) {
// wx.showModal({title:info.errMsg})
}
})
}
})
},
goshare_code(){
wx.navigateTo({
url: '../share_code/share_code',
success: function(res) {},
fail: function(res) {},
complete: function(res) {},
})
},
audioPlay: function (e) {//播放
let that=this;
that.setData({
play:false
})
bgM.src = that.data.musicsrc;
bgM.play();
setTimeout(() => {
bgM.currentTime
bgM.onTimeUpdate(() => {
let palyrate = (parseInt(bgM.currentTime) / parseInt(bgM.duration)) * 100;//播放的百分比
that.setData({
startsec: '00:' +(bgM.currentTime.toFixed(0) < 10 ? '0' + bgM.currentTime.toFixed(0) : bgM.currentTime.toFixed(0)),
endsec: '00:' +(bgM.duration.toFixed(0) < 10 ? '0' + bgM.duration.toFixed(0) : bgM.duration.toFixed(0)) ,
palyrate: palyrate
})
})
bgM.onEnded(() => {
that.setData({
startsec: '00' + ':00',
endsec: '00:' +( bgM.duration.toFixed(0) < 10 ? '0' + bgM.duration.toFixed(0) : bgM.duration.toFixed(0)) ,
palyrate: 0,
play: true
})
})
that.setData({
duration: bgM.duration
})
}, 1000)
},
audioPause: function () {//暂停
let that = this;
that.setData({
play: true
})
bgM.pause();
},
//根据坐标显示点
getlocationmap(location,id){
var that = this;
let markers = that.data.markers;
var key = config.Config.key;
var myAmapFun = new amapFile.AMapWX({ key: '856d7698b954d8c2356bce3a3be86f1d'});
myAmapFun.getRegeo({
iconPath: "../../images/yingfu.png",
iconWidth: 22,
iconHeight: 32,
location: location,
success: function (data) {
var newmarker = {
id: id,
latitude: data[0].latitude,
longitude: data[0].longitude,
iconPath: data[0].iconPath,
width: data[0].width,
height: data[0].height
}
markers[id] = newmarker;
that.setData({
markers: markers
});
console.log(that.data.markers)
that.setData({
latitude: data[0].latitude
});
that.setData({
longitude: data[0].longitude
});
that.setData({
textData: {
name: data[0].name,
desc: data[0].desc
}
})
},
fail: function (info) {
}
})
},
makertap(e) {
console.log(e);
var that = this;
var id = e.markerId;
},
getdata(){
let that=this;
let url ='home/home/click_one';
let params={
id: that.data.poster_id
}
app.post(url, params,{}).then((res)=>{
if(res.code==20000){
that.setData({
musicsrc: res.url
})
bgM.src = that.data.musicsrc;
for (let i in res.coordinate){
that.getlocationmap(res.coordinate[i], i);
}
}
}).catch((errMsg)=>{
})
},
//保存图片
saveImg() {
let that=this;
// let params = {
// pages: '/pages/share_record/share_record',
// scene: that.data.poster_id,
// }
console.log(typeof wx.getStorageSync('staticsrc'))
let params={
file: wx.getStorageSync('staticsrc'),
poster_id: that.data.poster_id,
page: 'pages/start/start'
}
// let url = 'home/home/code';
let url = 'home/home/poster';
app.post(url, params,{}).then((res) => {
if(res.code == 20000){
let imgUrl = res.url
wx.showLoading({
title: '加载中',
})
wx.downloadFile({
url: imgUrl,
success: function (res) {
wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: function (res) {
wx.hideLoading()
wx.showToast({
icon: 'none',
title: '图片保存成功,可以分享到朋友圈'
})
},
fail: function (res) {
wx.showToast({
icon: 'none',
title: '图片保存失败'
})
console.log(res)
}
})
},
fail: function (res) {
// wx.showModal({
// title: '提示',
// content: '图片保存失败,请重试',
// showCancel: false
// })
}
})
}
}).catch((errMsg) => {
// wx.showModal({
// title: '提示',
// content: errMsg,
// showCancel: false
// })
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let that=this;
that.setData({
poster_id: options.poster_id,
})
that.getdata();
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
bgM.pause();
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
/**
* 用户点击右上角分享
*/
onShareAppMessage: function (options) {
let that=this;
// 设置菜单中的转发按钮触发转发事件时的转发内容
var shareObj = {
title:'踏趣苏州', // 默认是小程序的名称(可以写slogan等)
path: '/pages/share_record/share_record?poster_id=' + that.data.poster_id, // 默认是当前页面,必须是以‘/’开头的完整路径
imgUrl: '',//自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径,支持PNG及JPG,不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
success: function (res) {
// 转发成功之后的回调
if (res.errMsg == 'shareAppMessage:ok') { }
},
fail: function () {
// 转发失败之后的回调
if (res.errMsg == 'shareAppMessage:fail cancel') {
// 用户取消转发
} else if (res.errMsg == 'shareAppMessage:fail') {
// 转发失败,其中 detail message 为详细失败信息
}
},
complete: function () {
// 转发结束之后的回调(转发成不成功都会执行)
}
}   // 来自页面内的按钮的转发
if (options.from == 'button') {
// 此处可以修改 shareObj 中的内容
// shareObj.path = '/pages/start/start?status=' + options.target.dataset.status
}   // 返回shareObj
return shareObj;
}
})
\ No newline at end of file
... ...
{
"navigationBarTitleText": "踏趣苏州"
}
\ No newline at end of file
... ...
<!--pages/record/record.wxml-->
<view class='bg'>
<image src='../../images/bg@2x.jpg'></image>
<view class='top_text'>
<view class='mini_title'>去过的地方,就是连接起来的一段脚步音符</view>
<view class='title'>来制作你的音乐logo吧</view>
</view>
<view class='center_img'>
<view class='map_container'>
<block wx:if='{{src}}'>
<image src='{{src}}'></image>
</block>
<block>
<map class="map" id="map" longitude="{{longitude}}" latitude="{{latitude}}" show-location="true" scale="{{scale}}" markers="{{markers}}" bindmarkertap="makertap" ></map>
</block>
</view>
</view>
<view class='bottom_box'>
<view class='play_box'>
<view class='play_left' bindtap="audioPlay" wx:if='{{play}}'>
<image src='../../images/zanting@2x.png'></image>
</view>
<view class='play_left' bindtap="audioPause" wx:else>
<image src='../../images/bofang@2x.png'></image>
</view>
<view class='play_rigth'>
<view class='play_text'>来听听你的专属脚步音乐logo</view>
<audio src="" id="myAudio" loop duration currentTime></audio>
<view class='play_control'>
<view class='play_item_yes' style="width:{{palyrate}}%">
</view>
<view class='silde_item' style="left:{{palyrate}}%"></view>
<view class='play_item_no' style="width:{{100-palyrate}}%"></view>
<view class='play_num'>
<view>{{startsec}}</view>
<view>{{endsec}}</view>
</view>
</view>
</view>
</view>
<view class='btn_box'>
<button class='btn' open-type='share'>转发到好友或群聊</button>
<view class='btn end_btn' bindtap='saveImg'>保存图片后发至朋友圈让更多好友听到</view>
</view>
</view>
</view>
\ No newline at end of file
... ...
/* pages/record/record.wxss */
@import "../index/index.wxss";
.center_img {
top:18%;
width:100%;
height:500rpx;
}
.bottom_box{
position:absolute;
left:50%;
transform: translateX(-50%);
bottom:5%;
width:560rpx;
overflow: hidden;
}
.play_box{
width:560rpx;
height: 132rpx;
border-radius: 10rpx;
background-color: #fff;
padding:0 20rpx;
box-sizing: border-box;
display: flex;
overflow: hidden;
align-items: center;
}
.play_left{
width:88rpx;
height: 88rpx;
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
}
.play_rigth{
position: relative;
width:420rpx;
margin:0 0 0 12rpx;
}
.play_left image{
width:100%;
height: 100%;
}
.play_text{
text-align: center;
color:#333030;
font-size:24rpx;
}
.play_rigth audio{
height: 34rpx;
}
.btn_box{
margin:16rpx 0 0 0;
width:560rpx;
background-color: #fff;
padding:30rpx 20rpx;
border-radius: 10rpx;
box-sizing: border-box;
}
.btn{
width:520rpx;
height: 80rpx;
display: flex;
justify-content: center;
align-items: center;
color:#fff;
border-radius: 40rpx;
background-color: #007CC2;
font-size:32rpx;
}
.end_btn{
margin:36rpx 0 0 0;
font-size:28rpx;
}
.play_control{
top:40rpx;
width:100%;
height: 100%;
padding:10rpx 0 0 0;
position: absolute;
}
.play_item_yes{
width:0;
position: relative;
float: left;
height: 6rpx;
background-color: #007CC2;
}
.silde_item{
left: 0;
top:4rpx;
z-index:100;
position: absolute;
height: 20rpx;
width:8rpx;
background-color: #007CC2;
}
.play_item_no{
width:100%;
float: right;
height: 6rpx;
background-color: #999;
}
.play_num{
width:100%;
display: flex;
justify-content: space-between;
align-items: center;
color:#007CC2;
font-size:24rpx;
}
.play_num.notime{
opacity: 0
}
.map_container{
width:100%;
height: 100%;
}
.map_container map{
width:100%;
height: 100%;
}
\ No newline at end of file
... ...
// pages/share_code.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"navigationBarTitleText": "踏趣苏州"
}
\ No newline at end of file
... ...
<!--pages/share_code.wxml-->
<view class='bg'>
<image src='../../images/bg@2x.png'></image>
<view class='top_text'>
<view class='mini_title'>去过的地方,就是连接起来的一段脚步音符</view>
<view class='title'>来制作你的音乐logo吧</view>
</view>
<view class='center_img'>
<image src='../../images/suzhou@2x.png'></image>
</view>
<view class='code_box'></view>
</view>
... ...
/* pages/share_code.wxss */
@import "../index/index.wxss";
.code_box{
position:absolute;
right:7%;
bottom:26%;
z-index:4;
background-color:#000;
width:137rpx;
height:137rpx;
overflow:hidden;
}
.code_box image{
width:100%;
height: 100%;
}
\ No newline at end of file
... ...
// pages/record/record.js
const app = getApp();
var amapFile = require('../../libs/amap-wx.js');
var config = require('../../libs/config.js');
var bgM = wx.createInnerAudioContext();
Page({
/**
* 页面的初始数据
*/
data: {
play: true, //true为播放,flase暂停
//地图数据
markers: [],//显示点的坐标对象
latitude: '',//当前显示的点维度
longitude: '',//当前显示点的经度
scale: '12',
src: '',
startsec: '00:00',
endsec: '00:00',
palyrate: '',//播放的百分比
musicsrc: ''
},
audioPlay: function (e) {//播放
let that = this;
that.setData({
play: false
})
bgM.src = that.data.musicsrc;
bgM.play();
setTimeout(() => {
bgM.currentTime
bgM.onTimeUpdate(() => {
let palyrate = (parseInt(bgM.currentTime) / parseInt(bgM.duration)) * 100;//播放的百分比
that.setData({
startsec: '00:' + (bgM.currentTime.toFixed(0) < 10 ? '0' + bgM.currentTime.toFixed(0) : bgM.currentTime.toFixed(0)),
endsec: '00:' + (bgM.duration.toFixed(0) < 10 ? '0' + bgM.duration.toFixed(0) : bgM.duration.toFixed(0)),
palyrate: palyrate
})
})
bgM.onEnded(() => {
that.setData({
startsec: '00' + ':00',
endsec: '00:' + (bgM.duration.toFixed(0) < 10 ? '0' + bgM.duration.toFixed(0) : bgM.duration.toFixed(0)),
palyrate: 0,
play: true
})
})
that.setData({
duration: bgM.duration
})
}, 1000)
},
audioPause: function () {//暂停
let that = this;
that.setData({
play: true
})
bgM.pause();
},
//根据坐标显示点
getlocationmap(location, id) {
var that = this;
let markers = that.data.markers;
var key = config.Config.key;
var myAmapFun = new amapFile.AMapWX({ key: '856d7698b954d8c2356bce3a3be86f1d' });
myAmapFun.getRegeo({
iconPath: "../../images/yingfu.png",
iconWidth: 22,
iconHeight: 32,
location: location,
success: function (data) {
var newmarker = {
id: id,
latitude: data[0].latitude,
longitude: data[0].longitude,
iconPath: data[0].iconPath,
width: data[0].width,
height: data[0].height
}
markers[id] = newmarker;
that.setData({
markers: markers
});
console.log(that.data.markers)
that.setData({
latitude: data[0].latitude
});
that.setData({
longitude: data[0].longitude
});
that.setData({
textData: {
name: data[0].name,
desc: data[0].desc
}
})
},
fail: function (info) {
}
})
},
makertap(e) {
console.log(e);
var that = this;
var id = e.markerId;
},
goindex(){
wx.reLaunch({
url: '../start/start',
success: function(res) {},
fail: function(res) {},
complete: function(res) {},
})
},
getdata(id){
let that = this;
let url = 'home/home/click_one';
let params = {
id: id
}
app.post(url, params,{}).then((res) => {
if (res.code == 20000) {
that.setData({
musicsrc: res.url
})
for (let i in res.coordinate) {
that.getlocationmap(res.coordinate[i], i);
}
}
}).catch((errMsg) => {
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let that=this;
if (options.poster_id != undefined){
var poster_id = decodeURIComponent(options.poster_id)
that.getdata(poster_id);
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
bgM.pause();
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{"navigationBarTitleText": "踏趣苏州"}
\ No newline at end of file
... ...
<!--pages/share_record/share_record.wxml-->
<!--pages/record/record.wxml-->
<view class='bg'>
<image src='../../images/bg@2x.jpg'></image>
<view class='top_text'>
<view class='mini_title'>去过的地方,就是连接起来的一段脚步音符</view>
<view class='title'> 来听听我制作的音乐logo吧</view>
</view>
<view class='center_img'>
<view class='map_container'>
<block wx:if='{{src}}'>
<image src='{{src}}'></image>
</block>
<block>
<map class="map" id="map" longitude="{{longitude}}" latitude="{{latitude}}" show-location="true" scale="{{scale}}" markers="{{markers}}" bindmarkertap="makertap" ></map>
</block>
</view>
</view>
<view class='bottom_box'>
<view class='play_box'>
<view class='play_left' bindtap="audioPlay" wx:if='{{play}}'>
<image src='../../images/zanting@2x.png'></image>
</view>
<view class='play_left' bindtap="audioPause" wx:else>
<image src='../../images/bofang@2x.png'></image>
</view>
<view class='play_rigth'>
<view class='play_text'>来听听她的专属脚步音乐logo</view>
<audio src="" id="myAudio" loop duration currentTime></audio>
<view class='play_control'>
<view class='play_item_yes' style="width:{{palyrate}}%">
</view>
<view class='silde_item' style="left:{{palyrate}}%"></view>
<view class='play_item_no' style="width:{{100-palyrate}}%"></view>
<view class='play_num'>
<view>{{startsec}}</view>
<view>{{endsec}}</view>
</view>
</view>
</view>
</view>
<view class='btn_box'>
<view class='btn' bindtap='goindex'>制作你的音乐logo吧!</view>
</view>
</view>
</view>
\ No newline at end of file
... ...
/* pages/record/record.wxss */
@import "../index/index.wxss";
.center_img {
top:18%;
width:100%;
height:500rpx;
}
.bottom_box{
position:absolute;
left:50%;
transform: translateX(-50%);
bottom:5%;
width:560rpx;
overflow: hidden;
}
.play_box{
width:560rpx;
height: 132rpx;
border-radius: 10rpx;
background-color: #fff;
padding:0 20rpx;
box-sizing: border-box;
display: flex;
overflow: hidden;
align-items: center;
}
.play_left{
width:88rpx;
height: 88rpx;
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
}
.play_rigth{
position: relative;
width:420rpx;
margin:0 0 0 12rpx;
}
.play_left image{
width:100%;
height: 100%;
}
.play_text{
text-align: center;
color:#333030;
font-size:24rpx;
}
.play_rigth audio{
height: 34rpx;
}
.btn_box{
margin:16rpx 0 0 0;
width:560rpx;
background-color: #fff;
padding:30rpx 20rpx;
border-radius: 10rpx;
box-sizing: border-box;
}
.btn{
width:520rpx;
height: 80rpx;
display: flex;
justify-content: center;
align-items: center;
color:#fff;
border-radius: 40rpx;
background-color: #007CC2;
font-size:32rpx;
}
.end_btn{
margin:36rpx 0 0 0;
font-size:28rpx;
}
.play_control{
top:40rpx;
width:100%;
height: 100%;
padding:10rpx 0 0 0;
position: absolute;
}
.play_item_yes{
width:0;
position: relative;
float: left;
height: 6rpx;
background-color: #007CC2;
}
.silde_item{
left: 0;
top:4rpx;
z-index:100;
position: absolute;
height: 20rpx;
width:8rpx;
background-color: #007CC2;
}
.play_item_no{
width:100%;
float: right;
height: 6rpx;
background-color: #999;
}
.play_num{
width:100%;
display: flex;
justify-content: space-between;
align-items: center;
color:#007CC2;
font-size:24rpx;
}
.map_container{
width:100%;
height: 100%;
}
.map_container map{
width:100%;
height: 100%;
}
\ No newline at end of file
... ...
// pages/start/start.js
const app =getApp();
Page({
/**
* 页面的初始数据
*/
data: {
},
start(e){
let that = this;
let encryptedData = e.detail.encryptedData;
let iv = e.detail.iv;
let raw_data = e.detail.rawData;
let signature = e.detail.signature;
wx.login({
success: (res) => {
let url = 'wxapp/public/getSessionKey';
let params = {
code: res.code
}
app.post(url, params,{}).then((res) => {
if(res.code==20000){
wx.setStorageSync('openid', res.data.openid);
wx.setStorageSync('session_key', res.data.session_key);
that.getlogin(res.data.openid, res.data.session_key, encryptedData, iv, raw_data, signature);
}
}).catch((errMsg) => {
console.log(errMsg)
})
}
})
},
getlogin(openid, session_key, encrypted_data, iv, raw_data, signature){
let url ='wxapp/public/login';
let params={
openid: openid,
session_key: session_key,
encrypted_data: encrypted_data,
iv: iv,
raw_data: raw_data,
signature: signature
}
app.post(url,params).then((res)=>{
if(res.code==20000){
wx.setStorageSync('token', res.data.token);
wx.setStorageSync('user_type', res.data.user_type);
wx.reLaunch({
url: '../index/index',
})
}
}).catch((errMsg)=>{
console.log(errMsg)
})
},
goindex(){
wx.reLaunch({
url: '../index/index',
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let that=this;
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{"navigationBarTitleText": "踏趣苏州"}
\ No newline at end of file
... ...
<!--pages/start/start.wxml-->
<view class='bg'>
<image src='../../images/bgg@2x.jpg'></image>
<button class='start_btn' open-type='getUserInfo' bindgetuserinfo='start' >来制作属于自己的音乐LOGO</button>
</view>
... ...
/* pages/start/start.wxss */
@import '../index/index.wxss';
.start_btn {
position: absolute;
z-index:3;
color:#fff;
font-size:32rpx;
width:520rpx;
height:80rpx;
line-height:80rpx;
text-align:center;
bottom:10%;
left:50%;
transform:translateX(-50%);
background-color:#007CC2;
border-radius:40rpx;
}
.start_btn:active{
opacity: 0.7;
}
\ No newline at end of file
... ...
{
"description": "项目配置文件。",
"packOptions": {
"ignore": []
},
"setting": {
"urlCheck": true,
"es6": true,
"postcss": true,
"minified": true,
"newFeature": true
},
"compileType": "miniprogram",
"libVersion": "2.2.5",
"appid": "wx11570b7f6228bd65",
"projectname": "%E8%B8%8F%E5%AF%BB%E8%8B%8F%E5%B7%9Eend",
"isGameTourist": false,
"condition": {
"search": {
"current": -1,
"list": []
},
"conversation": {
"current": -1,
"list": []
},
"plugin": {
"current": -1,
"list": []
},
"game": {
"currentL": -1,
"list": []
},
"miniprogram": {
"current": -1,
"list": [
{
"id": -1,
"name": "生成二维码",
"pathName": "pages/record/record",
"query": "id=6"
}
]
}
}
}
\ No newline at end of file
... ...
const formatTime = date => {
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
const hour = date.getHours()
const minute = date.getMinutes()
const second = date.getSeconds()
return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}
const formatNumber = n => {
n = n.toString()
return n[1] ? n : '0' + n
}
module.exports = {
formatTime: formatTime
}
... ...