他はますます達成し、市場の需要に、独自の小さなプログラムのプラットフォームを作った後、開発の最近の2年後、アプレットの状態は徐々に高く高く、各プラットフォームの1を取得している、ユニアプリが利用Vue.jsですすべてのフロントエンドアプリケーション開発フレームワークは、開発者がコードの1セットを書き、あなたは、iOS、Androidの、H5への公開、そして小さなプログラム(マイクロチャネル/アリペイ/百度/ヘッドライン/ QQ /爪)や他のプラットフォームの様々なことができます。でも、クロス終了せずに、ユニアプリは、少し良く開発フレームワークです。
レンダリング
図1に示すように、位置情報を取得します
機能を配置するには、手順は、テンセントは、APIとAPIインタフェーステンセントの天気をマップに使用、
あなたのお母さんの独自の程度で登録手順を詳細に得られた我々はAPPKEY登録で必要なデータを要求する公式ウェブサイト登録の開発者アカウントに移動する必要性
に起因します使用位置決めする必要がgetLocationメソッドのuniappは、現在位置の座標を得ることで、対応するテンセントマップ特定の都市
uni.getLocation({
// #ifdef MP-WEIXIN
type: 'wgs84',
// #endif
async success (res) {
const {latitude, longitude} = res
const result = await that.ajax({url: 'https://apis.map.qq.com/ws/geocoder/v1', data: {
location: `${latitude},${longitude}`,
key: ''
}})
let {province, city, district} = result.result.address_component
that.getData(province, city, district)
},
fail(){
uni.showModal({
content: '检测到您没打开定位权限,是否去设置打开?',
confirmText: "确认",
cancelText: "取消",
success: function (res) {
if (res.confirm) {
// #ifdef MP-WEIXIN
wx.openSetting({
success: (res) => {
that.getIn()
}
})
// #endif
// #ifdef MP-ALIPAY
my.openSetting({
success: (res) => {
that.getIn()
}
})
// #endif
}
}
});
}
})
web前端开发学习Q-q-u-n: 784783012 ,分享学习的方法和需要注意的小细节,不停更新最新的教程和学习方法
(详细的前端项目实战教学视频,PDF)
天気予報をチェックしてください2。
天候インターフェイスを都市名、都市名を取得してから確認した後、次の数日の天気予報を取得します。
テンセント気象気象インタフェースは、インタフェースAPIを使用しています。
小さなプログラムの設定インタフェースを追加する要求でのアプレットで使用する、合法的なドメイン名の前に、設定を開発しました。
methods: {
async getData(province, city, district){
const that = this
const data = await that.ajax({url: 'https://wis.qq.com/weather/common', data: {
source: 'xw',
weather_type: 'observe|alarm|air|forecast_1h|forecast_24h|index|limit|tips|rise',
province: province,
city: city,
county: district
}})
that.region = [province, city, district]
if(data.status != 200){
uni.showToast({
title: result.message,
icon: 'none'
});
return false;
}
if(!data.data.air.aqi_name){
uni.showToast({
title: '暂无该地区的天气信息',
icon: 'none'
});
return false;
}
that.data = data.data
}
}
図3に示すように、小さなプログラム・インターフェース
行うには美的、想像力の欠如、参照テンセント天気インタフェースが存在しないため。この関数は、最後の24時間の気象条件や最近6日間の気象条件、今日の旧正月のショーの時間を表示するために地域の他の部分で、天候やスイッチング電流天気予報をチェック、非常に簡単です。
図4に示すように、プラグインの使用
すぐに折れ線グラフを使用しています小さなプログラム、構築したいuchart.jsを、
プログラムがアリペイ小零細文字アプレットと互換性があるため、プラグインもルナクエリで使用されているcalendar.js
アリペイ折れ線グラフのアプレットで問題がぼやけになりますこれは、互換性のある処理を行う必要があります
<template>
<!-- #ifdef MP-ALIPAY -->
<canvas canvas-id="canvas" id="canvas" width="750" height="240" style="width:750rpx;height:240rpx;" class="canvas">
</canvas>
<!-- #endif -->
<!-- #ifdef MP-WEIXIN -->
<canvas canvas-id="canvas" id="canvas" class="canvas">
</canvas>
<!-- #endif -->
</template>
<script>
var wxCharts = require('../../utils/chart.js');
lineChart = new wxCharts({
$this: this,
canvasId: 'canvas',
type: 'line',
categories: ['', '', '', '', '' ,''],
colors: ['#ffad35', '#4fc3f7'],
background: '#fff',
animation: true,
series: [{
name: '',
data: that.max,
format: function (val, name) {
return val + '°';
}
}, {
name: '',
data: that.min,
format: function (val, name) {
return val + '°';
}
}],
xAxis: {
disableGrid: true,
disabled: true,
axisLine: false
},
yAxis: {
max: Math.max.apply(Math, that.max) * 1 + 0.1,
disabled: true,
disableGrid: true,
},
legend:{
show: false
},
// #ifdef MP-ALIPAY
pixelRatio: that.pixelRatio, // 解决支付宝模糊问题
// #endif
width: that.cWidth,
height: that.cHeight
});
</script>
web前端开发学习Q-q-u-n: 784783012 ,分享学习的方法和需要注意的小细节,不停更新最新的教程和学习方法
(详细的前端项目实战教学视频,PDF)
選択コンポーネントとマイクロ手紙アプレット市、都市の構成要素は、直接アリペイ、uniapp公式の説明を使用していません:インストールmpvueコンポーネントをサポートしていますが、NPMモードを見つけるために、(例えばwxml形式vant-weappなど)アプレットカスタムコンポーネントをサポートしていません。アリペイプラグインの都市を使用することができます。mpvue-citypicker、
市は、コンポーネントを選択します
<template>
<view class="txt-location" @tap="showCityPicker">
<view class="icon"></view>
<block v-if="region.length">{{region[0]}}{{region[1]}}{{region[2]}}</block>
<block v-else>选择城市</block>
<!-- #ifdef MP-WEIXIN -->
<picker class="city" mode="region" @change="handleChange" :value="region">
<view class="picker">
当前选择:{{region[0]}},{{region[1]}},{{region[2]}}
</view>
</picker>
<!-- #endif -->
</view>
<mpvue-city-picker ref="mpvueCityPicker" :pickerValueDefault="pickerValueDefault" @onConfirm="onConfirm"></mpvue-city-picker>
</template>
<script>
import mpvueCityPicker from 'mpvue-citypicker';
export default {
data() {
return {
region: [],
pickerValueDefault: [0, 0, 1]
};
},
components: {
mpvueCityPicker
},
methods: {
showCityPicker() {
// #ifdef MP-ALIPAY
this.$refs.mpvueCityPicker.show()
// #endif
},
onConfirm(e) {
if(e.label){
this.region = e.label.split('-')
this.getData(this.region[0], this.region[1], this.region[2])
}
},
handleChange(e) {
this.region = e.detail.value
this.getData(this.region[0], this.region[1], this.region[2])
}
}
};
</script>
web前端开发学习Q-q-u-n: 784783012 ,分享学习的方法和需要注意的小细节,不停更新最新的教程和学习方法
(详细的前端项目实战教学视频,PDF)