123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- <template>
- <view class="box">
- <button type="default" @click="getCode">点击扫一扫</button>
- <view class="">
- <view class="">
- 昵称: {{ data.nickname }}
- </view>
- <view class="">
- 手机号: {{ data.phone }}
- </view>
- <view class="">
- 款式: {{ data.style }}
- </view>
- <view class="">
- 价格: {{ data.price }}
- </view>
- <view class="">
- 出库时间: {{ data.time }}
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- LookTime
- } from '../../apis/fangwei.js'
- import {
- location,
- } from '../../apis/user.js';
- var jweixin = require('jweixin-module');
- export default {
- name: 'ShareIndex',
- data() {
- return {
- model: '',
- data: {},
- }
- },
- onLoad: function(option) {
- // const result = 'http://fangw.jiuweiyun.cn/api/auth/2212091738582BQYOWI60104'
- // var site = result.lastIndexOf('\/')
- // var params = result.substring(site + 1, result.length)
- // this.code = window.encodeURIComponent(params)
- // this.getTime(this.code)
- // 用于扫码发货
- uni.getSystemInfo({
- success: res => {
- this.model = res.model
- }
- })
- if (this.model == 'iPhone') {
- uni.setStorageSync('url', window.location.href.split('#')[0])
- }
- },
- methods: {
- getTime(params) {
- LookTime({ code: params }).then(res => {
- if (res.code == 200) {
- this.data = res.data
- } else {
- uni.showModal({
- title: '错误提示',
- content: res.message || '获取信息失败',
- showCancel: false
- })
- }
- })
- },
- getCode() {
- let link = window.location.href;
- let url = this.model == 'iPhone' ? uni.getStorageSync('url') : link
- location({
- url
- }).then(res => {
- if (res.code == 200) {
- let data = JSON.parse(res.data);
- // 判断是否支持扫码
- jweixin.config({
- debug: false, //开启debug模式.正式环境设置为false,测试环境设置为true
- appId: data.appId,
- timestamp: data.timestamp,
- nonceStr: data.nonceStr,
- signature: data.signature,
- jsApiList: ['scanQRCode'] //根据需要看需要哪些SDK的功能
- });
- // sdk加载完成后执行
- jweixin.ready(() => {
- jweixin.checkJsApi({
- jsApiList: ['scanQRCode'],
- success: res => {
- if (res.checkResult.scanQRCode == false) {
- alert('你的微信版本太低,不支持微信JS接口,请升级到最新的微信版本!');
- return;
- }
- }
- });
- jweixin.error(res => {
- console.log(res.errMsg, '错误消息');
- });
- //扫码
- jweixin.scanQRCode({
- needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
- scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码,默认二者都有
- success: res => {
- var result = res.resultStr; // 当needResult 为 1 时,扫码返回的结果
- var site = result.lastIndexOf('\/')
- var params = result.substring(site + 1, result.length)
- this.code = window.encodeURIComponent(params)
- this.getTime(this.code)
- },
- fail: () => {
- location.href = location.protocol + '//' + location.host +
- "/pages/scanC/scanC";
- },
- });
- });
- } else {
- uni.showModal({
- title: '错误提示',
- content: res.message || '获取信息失败',
- showCancel: false
- })
- }
- })
- }
- }
- }
- </script>
- <style scoped lang="scss" scoped>
- .box {
- padding: 30rpx;
- font-size: 30rpx;
- view {
- margin-top: 20rpx;
- }
- }
- #share_container {
- width: 100%;
- height: 100%;
- display: flex;
- justify-content: space-between;
- flex-direction: column;
- }
- #imgWrapper {
- flex: 1;
- @include flex();
- .showCan {
- width: 680rpx;
- height: 960rpx;
- border-radius: 14rpx;
- box-shadow:0px 0px 23px 2px rgba(194,133,58,0.5);
- }
- }
- .sharetext {
- font-size: 80rpx;
- text-align: center;
- margin: 8rpx 0;
- box-sizing: border-box;
- padding: 30rpx 24rpx;
- }
- </style>
|