123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- "use strict";
- var common_vendor = require("../../common/vendor.js");
- var api_home = require("../../api/home.js");
- require("../../common/request.js");
- const isWechat = () => {
- return String(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)) === "micromessenger";
- };
- const _sfc_main = {
- data() {
- return {
- isLogin: false,
- code: "",
- livedata: {},
- path: "http://live.ylrzcloud.com/prod-api",
- iskefu: false,
- isLongPress: false,
- timeout: null,
- liveId: 2
- };
- },
- onLoad(option) {
- },
- onShow() {
- if (common_vendor.index.getStorageSync("AppToken")) {
- this.getliving();
- }
- },
- methods: {
- open() {
- },
- close() {
- this.iskefu = !this.iskefu;
- },
- longPress() {
- this.timeout = setTimeout(() => {
- this.isLongPress = true;
- common_vendor.index.saveImageToPhotosAlbum({
- filePath: this.livedata.qwQrCode,
- success: () => {
- common_vendor.index.showToast({
- title: "\u4FDD\u5B58\u6210\u529F"
- });
- },
- fail: () => {
- common_vendor.index.showToast({
- title: "\u4FDD\u5B58\u5931\u8D25",
- icon: "none"
- });
- }
- });
- }, 500);
- },
- cancelLongPress() {
- clearTimeout(this.timeout);
- this.isLongPress = false;
- },
- getliving() {
- const param = {
- id: this.liveId
- };
- api_home.getlive(param).then((res) => {
- if (res.code == 200) {
- this.livedata = res.data;
- } else {
- common_vendor.index.showToast({
- title: res.msg,
- icon: "none",
- duration: 2e3
- });
- }
- });
- },
- getWechatCode() {
- if (isWechat) {
- let appid = "wx93ce67750e3cfba3";
- let code = this.getUrlCode().code;
- let local = window.location.href.split("#")[0];
- if (code == null || code === "") {
- window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appid + "&redirect_uri=" + encodeURIComponent(local) + "&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
- } else {
- this.code = code;
- this.loginByMp();
- }
- }
- },
- loginByMp() {
- if (this.code == null) {
- return;
- }
- common_vendor.index.showLoading({
- title: "\u5904\u7406\u4E2D..."
- });
- var data = {
- code: this.code
- };
- api_home.loginByMp(data).then((res) => {
- common_vendor.index.hideLoading();
- if (res.code == 200) {
- console.log(res);
- common_vendor.index.setStorageSync("AppToken", res.token);
- common_vendor.index.setStorageSync("userInfo", JSON.stringify(res.user));
- let beforLoginUrl = common_vendor.index.getStorageSync("beforLoginPage");
- common_vendor.index.reLaunch({
- url: beforLoginUrl
- });
- common_vendor.index.showToast({
- title: "\u767B\u5F55\u6210\u529F",
- icon: "none"
- });
- this.getliving();
- } else {
- common_vendor.index.showToast({
- title: res.msg,
- icon: "none"
- });
- }
- }, (err) => {
- });
- },
- getUrlCode() {
- var url = location.search;
- var theRequest = new Object();
- if (url.indexOf("?") != -1) {
- var str = url.substr(1);
- var strs = str.split("&");
- for (var i = 0; i < strs.length; i++) {
- theRequest[strs[i].split("=")[0]] = strs[i].split("=")[1];
- }
- }
- return theRequest;
- },
- comelive() {
- common_vendor.index.setStorageSync("AppToken", null);
- if (common_vendor.index.getStorageSync("AppToken")) {
- common_vendor.index.navigateTo({
- url: "/pages/home/living"
- });
- } else {
- common_vendor.index.showToast({
- title: "\u8BF7\u767B\u5F55\u6388\u6743\uFF01",
- icon: "none"
- });
- common_vendor.index.navigateTo({
- url: "/pages/auth/login"
- });
- }
- }
- }
- };
- if (!Array) {
- const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
- const _easycom_u_popup2 = common_vendor.resolveComponent("u-popup");
- (_easycom_u_icon2 + _easycom_u_popup2)();
- }
- const _easycom_u_icon = () => "../../uni_modules/uview-plus/components/u-icon/u-icon.js";
- const _easycom_u_popup = () => "../../uni_modules/uview-plus/components/u-popup/u-popup.js";
- if (!Math) {
- (_easycom_u_icon + _easycom_u_popup)();
- }
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
- return {
- a: $data.livedata.liveImgUrl,
- b: common_vendor.t($data.livedata.liveName),
- c: common_vendor.t($data.livedata.startTime),
- d: common_vendor.t($data.livedata.finishTime),
- e: $data.livedata.liveDesc,
- f: common_vendor.o((...args) => $options.comelive && $options.comelive(...args)),
- g: common_vendor.o(($event) => _ctx.showadd = !_ctx.showadd),
- h: common_vendor.p({
- name: "close",
- size: "18"
- }),
- i: _ctx.codeimg,
- j: common_vendor.o((...args) => $options.longPress && $options.longPress(...args)),
- k: common_vendor.o((...args) => $options.cancelLongPress && $options.cancelLongPress(...args)),
- l: common_vendor.o($options.close),
- m: common_vendor.o($options.open),
- n: common_vendor.p({
- show: $data.iskefu,
- round: "20rpx",
- bgColor: "#fffee1"
- })
- };
- }
- var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-71e217db"], ["__file", "C:/Users/Administrator/Desktop/\u9879\u76EE/\u76F4\u64AD/liveH5-v3/pages/home/index.vue"]]);
- wx.createPage(MiniProgramPage);
|