Commit 6d95719d authored by 贺燕敏's avatar 贺燕敏

update

parent e5931b80
File added
# lwjtgb
路网交通广播小程序代码
\ No newline at end of file
#### 项目介绍
交通广播
#### 软件架构
软件架构说明
#### 安装教程
1. xxxx
2. xxxx
3. xxxx
#### 使用说明
1. xxxx
2. xxxx
3. xxxx
#### 参与贡献
1. Fork 本项目
2. 新建 Feat_xxx 分支
3. 提交代码
4. 新建 Pull Request
#### 码云特技
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
2. 码云官方博客 [blog.gitee.com](https://blog.gitee.com)
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解码云上的优秀开源项目
4. [GVP](https://gitee.com/gvp) 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目
5. 码云官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
6. 码云封面人物是一档用来展示码云会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
\ No newline at end of file
//app.js
App({
onLaunch: function() {
// 展示本地存储能力
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
var self = this
// 登录
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
wx.request({
url: 'https://sdsw.rooodad.com/' + 'rooodad/wx_login',
data: {
js_code: res.code,
appid:"wxab219319d77db3bb",
secret:"b94c44565b5a0b228c778bdbc156d842"
},
method: "POST",
header: {
'content-type': 'application/json' // 默认值
},
success: function(res) {
console.log(res)
if (res.statusCode == "200") {
var openid = res.data.openid;
var userid = res.data.userid;
self.globalData.userIds = {}
self.globalData.userIds.openid = (openid ? openid : "")
self.globalData.userIds.userid = (userid ? userid : "")
self.globalData.userid_flag = 1;
console.log(self.globalData.userIds)
// getData(self.globalData.userIds.openid)
} else {
wx.showToast({
title: res.errMsg,
icon: 'none',
duration: 2000
})
}
}
})
}
})
// 获取用户信息
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)
}
}
})
}
}
})
wx.request({
url: 'https://if.auto.soooner.com/lwtt04',
data: {
userid:"3a46de656b014719ad1ab4fcbd50901d",
token:"tomorrow"
},
method:"POST",
header: {
'content-type': 'application/json' // 默认值
},
success(res) {
console.log(res)
self.globalData.lkData = {
distance: res.data.distance,
timespan: res.data.timespan
}
}
})
},
globalData: {
userInfo: null,
lkData:null,
httpUrl:'https://if.auto.soooner.com/'
}
})
\ No newline at end of file
{
"pages": [
"pages/index/index",
"pages/detail/detail"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "路网交通广播",
"navigationBarTextStyle": "black"
}
}
\ No newline at end of file
/**app.wxss**/
.container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
background: #000
}
# lwjtgb
路网交通广播小程序代码
\ No newline at end of file
File added
// pages/detail.js
const app = getApp()
const util = require("../../utils/util.js")
Page({
/**
* 页面的初始数据
*/
data: {
current: {
poster: 'http://y.gtimg.cn/music/photo_new/T002R300x300M000003rsKF44GyaSk.jpg?max_age=2592000',
name: '此时此刻',
author: '许巍',
src: 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E06DCBDC9AB7C49FD713D632D313AC4858BACB8DDD29067D3C601481D36E62053BF8DFEAF74C0A5CCFADD6471160CAF3E6A&fromtag=46',
},
contentPlay: null ,
userInfo:null,
currentPlay:null,
typePlay:1,
audioAction: {
method: 'pause'
}
},
bindtimeupdate: function(e){
console.log(e.detail)
},
onLoad: function(options) {
var sel = this;
var userInfo = app.globalData.userInfo;
var contentPlay = app.globalData.contentPlay;
sel.setData({
userInfo: userInfo,
contentPlay : app.globalData.contentPlay
})
console.log(userInfo)
console.log(contentPlay)
wx.getSystemInfo({
success: function (res) {
console.log(res.windowHeight)
sel.setData({
height: res.windowHeight
})
}
})
// playAudio: function () {
// this.setData({
// audioAction: {
// method: 'play'
// }
// });
// },
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
}
})
\ No newline at end of file
{}
\ No newline at end of file
<!--pages/detail.wxml-->
<view class='container' style='min-height:{{height}}px'>
<view class='title-shell'>
<view class='user-avatar'>
<image class='avatar' src='{{userInfo.avatarUrl}}' mode='aspectFit'></image>
</view>
<view class='share'>
<image class='share-icon' src='../../utils/img/share@2x.png' mode='aspectFit'></image>
</view>
<view class='title-content'>
推荐
<view class="sub-title">根据您的爱好推荐,收听越多推荐越准</view>
</view>
</view>
<view class='fm-content'>
<audio class='' action="{{audioAction}}" bindtimeupdate="bindtimeupdate" src='{{current.src}}'></audio>
<view class='fm-bg-shell'>
<view class='voice-bg'>
<image class='voice-img' src='../../utils/img/temp.png' mode='widthFix'></image>
<!-- <swiper class='swiper' indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}">
<swiper-item>
<image class='voice-img' src='../../utils/img/temp.png' mode='widthFix'></image>
</swiper-item>
</swiper> -->
</view>
</view>
<view class='slider-shell'>
<slider class='slider' bindchange="sliderchange" backgroundColor="#CCCCCC" activeColor="#16A196" block-color="#16A196" block-size="12" left-icon="cancel" right-icon="success_no_circle" />
<view class='time'>
<view class="start-time">00:00</view>
<view class="sum-time">02:34</view>
</view>
</view>
<view class="audio-content" wx:if="{{typePlay == 1}}">
<view>{{currentPlay.title}}</view>
<view class='tips-shell'>
<view class='close'>×</view>
<view class='tags-shell' wx:>
<view class="tags">娱乐</view>
</view>
<view class='tags-shell'>
<view class='source'>@新闻直播间</view>
<view class='time-over'>4小时前</view>
</view>
</view>
</view>
<view class="audio-content" wx:else>
<view class="lkbb">
<image class='lkbb-img' mode='widthFix' src='../../utils/img/lkbb@2x.png'></image>
路况播报
</view>
<view class='fm-title'>四天凉了三位大主播,斗鱼风波还将继续!张大仙将是下一个目标?</view>
</view>
</view>
<view class='footer-btns'>
<view class='btns-shell'>
<image class='pap' mode='widthFix' src='../../utils/img/play@2x.png'></image>
<image class='pre' mode='widthFix' src='../../utils/img/pre@2x.png'></image>
<image class='next' mode='widthFix' src='../../utils/img/next@2x.png'></image>
</view>
</view>
</view>
\ No newline at end of file
/* pages/detail.wxss */
.container{
background: #fff;
position: relative
}
.title-shell{
position: absolute;
top: 0;
right: 0;
width: 100%;
height: 120rpx;
background: #fff;
border-bottom: 1px solid #ccc;
color: #333;
font-size: 18px;
font-weight: 600;
text-align: center;
}
.sub-title{
padding-top: 20rpx;
color: #666;
font-size:10px;
font-weight: normal;
}
.title-content{
}
.user-avatar{
position: absolute;
top: 24rpx;
left: 36rpx;
border: 2px solid #F2F2F2;
width: 64rpx;
height: 64rpx;
border-radius: 50%;
overflow: hidden
}
.share{
position: absolute;
top: 0;
right: 0;
width: 72rpx;
height: 78rpx;
}
.share-icon{
width: 36rpx;
height: 36rpx;
margin-top: 36rpx;
margin-right: 42rpx;
}
.avatar{
width: 64rpx;
height: 64rpx;
}
.fm-content{
margin-top: 120rpx;
width: 100%;
height: 100%
}
.fm-bg-shell{
height: 376rpx;
margin:40rpx;
border-radius: 16rpx;
overflow: hidden
}
.voice-bg{
width: 100%;
height: 100%;
}
.voice-img{
width: 100%;
}
.time{
color: #666;
font-size: 10px;
}
.time::after{
content: "";
display: table;
clear: both;
}
.start-time{
float: left
}
.sum-time{
float: right
}
.slider{
margin: 0;
}
.slider-shell{
padding: 0 40rpx
}
.audio-content{
padding:16rpx 40rpx;
color: #333;
font-size: 14px;
}
.tips-shell{
}
.close{
float: right;
color: #D0D0D0;
padding:0 14rpx;
border: 1px solid #d0d0d0;
border-radius: 10rpx;
}
.tags-shell{
width: 80%;
margin-top: 20rpx;
}
.tags-shell::after{
content: "";
display: table;
clear: both;
}
.tags{
float: left;
padding: 8rpx 20rpx;
font-size: 10px;
color: #16A196;
background: #EAF8F8;
border-radius: 4rpx;
}
.source{
float: left;
margin-right: 30rpx;
color: #333;
font-size: 12px;
}
.time-over{
float: left;
font-size: 12px;
color: #666;
}
.footer-btns{
position: absolute;
left: 0;
width: 100%;
height: 220rpx;
bottom: 0;
/* background: #f00; */
}
.btns-shell{
width: 60%;
height: 100%;
/* background: #ff0; */
margin: 0 auto;
position: relative;
}
.pap{
width: 140rpx;
position: absolute;
left: 50%;
margin-left: -70rpx;
border-radius: 50%;
box-shadow: 0 1px 10px 0 rgba(0, 0, 0, .2);
top: 50%;
margin-top: -70rpx;
}
.pre,.next{
width: 48rpx;
margin-top: 80rpx;
}
.pre{
float: left;
}
.next{
float: right
}
.lkbb-img{
width: 84rpx;
}
.lkbb{
width: 100rpx;
min-height: 150rpx;
float: left;
color: #808080;
text-align: center;
font-size: 11px;
margin-right: 10rpx;
}
.swiper{
width: 100%;
height: 100%;
}
\ No newline at end of file
//index.js
//获取应用实例
const app = getApp()
const util = require("../../utils/util.js")
Page({
data: {
latitude: 39.90,
longitude: 116.38,
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo'),
contentPlay:null,
isGetTT:false
},
//事件处理函数
bindViewTap: function() {
},
getShellSwiper:function(e){
console.log(e)
},
navigateTo: function(e){
wx.navigateTo({
url: '../detail/detail?mid=23'
})
},
onReady: function (e) {
var self = this;
wx.getLocation({
success: res => {
// app.globalData.userInfo = res.userInfo
console.log(res)
app.globalData.gps = {
"latitude": res.latitude,
"longitude": res.longitude
}
this.setData({
latitude: res.latitude,
longitude: res.longitude
})
this.mapCtx = wx.createMapContext('myMap');
}
})
var i = 0;
var timer = setInterval(function(){
// i++;
// console.log(i)
if(app.globalData.userid_flag == 1) {
console.log(i)
clearInterval(timer)
wx.request({
url: app.globalData.httpUrl+ 'lwtt02',
data: {
userid: app.globalData.userIds.openid,
token: "aNvHanzi"
},
method: "POST",
header: {
'content-type': 'application/json' // 默认值
},
success: function (res) {
if (res.statusCode == "200") {
app.globalData.contentPlay = res.data.list;
console.log(res.data.list)
self.setData({
contentPlay: res.data.list,
isGetTT:true
})
} else {
wx.showToast({
title: res.errMsg,
icon: 'none',
duration: 2000
})
}
}
})
}
},10)
// function getData(userid) {
// }
if (app.globalData.userInfo) {
console.log("11111")
this.setData({
userInfo: app.globalData.userInfo,
hasUserInfo: true
})
} else if (this.data.canIUse) {
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
console.log("22222")
app.userInfoReadyCallback = res => {
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
app.globalData.userInfo = res.userInfo
}
} else {
console.log("33333")
// 在没有 open-type=getUserInfo 版本的兼容处理
wx.getUserInfo({
success: res => {
app.globalData.userInfo = res.userInfo
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
}
// 获取定位信息、
// util.getData(gps.latitude, gps.longitude)
// 初始化数据
// util.getData(app.globalData.gps)
},
getUserInfo: function(e) {
console.log(e)
if (e.detail.userInfo) {
app.globalData.userInfo = e.detail.userInfo
var userIds = app.globalData.userIds
console.log(userIds)
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true,
userIds: userIds
})
var param = {
openid: app.globalData.userIds.openid,
userInfo: e.detail.userInfo,
signature: e.detail.signature,
rawData: e.detail.rawData,
iv: e.detail.iv,
encryptedData: e.detail.encryptedData,
appid:"wxab219319d77db3bb"
}
var self = this
if (!userIds.userid) {
wx.request({
url: 'https://sdsw.rooodad.com/' + 'rooodad/wx_getUserInfo',
data: param,
method: "POST",
header: {
'content-type': 'application/json' // 默认值
},
success: function (res) {
console.log(param)
console.log(res)
if (res.data.userid) {
userIds.userid = res.data.userid;
} else {
wx.showToast({
title: res.data.errmsg,
icon: 'none',
duration: 2000
})
}
}
})
app.globalData.userIds = userIds;
self.setData({ userIds: userIds })
}
} else {
this.setData({
hasUserInfo: true
})
}
}
})
\ No newline at end of file
{}
\ No newline at end of file
<!--index.wxml-->
<view class="container">
<view class='map-shell'>
<map
class='my-map'
id="myMap"
latitude="{{latitude}}"
longitude="{{longitude}}"
markers="{{markers}}"
covers="{{covers}}"
show-location
></map>
</view>
<view class='title-shell'>
推荐
<view class="sub-title">根据您的爱好推荐,收听越多推荐越准</view>
</view>
<view class='bottom-shell' wx:if="{{isGetTT}}">
<button class="getUserInfoBtn" wx:if="{{!hasUserInfo && canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"></button>
<view class="bottom-content" bindtap='navigateTo'>
<view class='lg-time'>
<image class='lwjtgb-logo' src='../../utils/img/lwjtgb@2x.png' mode='aspectFit'></image>
<view class='time'>8月3日 星期五</view>
</view>
<view class='lwjtgb-name'>{{contentPlay[0].title}}</view>
<view class='lanren'>懒人听 ></view>
</view>
</view>
</view>
\ No newline at end of file
/**index.wxss**/
.container{
background: #f7f7f7;
/* background: #f00; */
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
padding: 120rpx 0;
}
.my-map{
height: 100%;
width: 100%;
}
.map-shell{
position: absolute;
top: 120rpx;
bottom: 120rpx;
width: 100%;
}
.title-shell{
position: absolute;
top: 0;
right: 0;
width: 100%;
height: 120rpx;
background: #fff;
box-shadow: 0 1px 10px 1px rgba(0, 0, 0, .3);
color: #333;
font-size: 18px;
font-weight: 600;
text-align: center;
padding-top: 20rpx;
}
.sub-title{
padding-top: 20rpx;
color: #666;
font-size:10px;
font-weight: normal;
}
.bottom-shell{
width: 100%;
height: 120rpx;
position: absolute;
bottom: 0;
background: #fff;
box-shadow: 0 -1px 10px 1px rgba(0, 0, 0, .3);
}
.bottom-content{
width: 100%;
height: 100%;
padding: 20rpx 30rpx ;
box-sizing: border-box
}
.lg-time{
float: left;
width: 148rpx;
margin-right: 35rpx;
/* height: 80rpx; */
/* background: #ff0 */
}
.lwjtgb-logo{
width: 148rpx;
height: 24rpx;
}
.time{
color: #666;
font-size: 8px
}
.lwjtgb-name{
color: #333;
font-size: 12px;
width: 380rpx;
float: left;
padding-top: 10rpx;
}
.lanren{
color: #16A196;
font-size: 12px;
font-weight: 600;
line-height: 100rpx;
float: right
}
.getUserInfoBtn{
background: transparent;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
\ 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.4",
"appid": "wxab219319d77db3bb",
"projectname": "lwjtgb",
"isGameTourist": false,
"condition": {
"search": {
"current": -1,
"list": []
},
"conversation": {
"current": -1,
"list": []
},
"plugin": {
"current": -1,
"list": []
},
"game": {
"currentL": -1,
"list": []
},
"miniprogram": {
"current": 0,
"list": [
{
"id": -1,
"name": "detail",
"pathName": "pages/detail/detail",
"query": "mid=23",
"scene": "1008"
}
]
}
}
}
\ No newline at end of file
File added
const app = getApp()
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
}
const getlkData = function(latitude, longitude) {
wx.request({
url: app.globalData.httpUrl + 'lwtt14?gps=' + latitude + "," + longitude, //仅为示例,并非真实的接口地址
data: {},
header: {
'content-type': 'application/json' // 默认值
},
success(res) {
console.log(res.data)
}
})
}
const getDistance = function(lat1, lng1, lat2, lng2) {
lat1 = lat1 || 0;
lng1 = lng1 || 0;
lat2 = lat2 || 0;
lng2 = lng2 || 0;
var rad1 = lat1 * Math.PI / 180.0;
var rad2 = lat2 * Math.PI / 180.0;
var a = rad1 - rad2;
var b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0;
var r = 6378137;
return (r * 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(rad1) * Math.cos(rad2) * Math.pow(Math.sin(b / 2), 2)))).toFixed(0)
 
}
module.exports = {
formatTime: formatTime,
getlkData: getlkData,
getDistance: getDistance
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment