var webpackRequire = require("./../../../webpack-require");
webpackRequire(
"./src/packages/wm-cloud-db_webview/db_webview/index.js",
Object.assign({}, require("./../../../weimob-cloud-commons.js").modules, {

/***/ "./src/packages/wm-cloud-db_webview/db_webview/index.js":
/*!**************************************************************!*\
  !*** ./src/packages/wm-cloud-db_webview/db_webview/index.js ***!
  \**************************************************************/
/*! no exports provided */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _wm_cloud_db_index_utils_db_api_globalData__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../wm-cloud-db_index/utils/db_api/globalData */ "./src/packages/wm-cloud-db_index/utils/db_api/globalData.js");
/* harmony import */ var _wm_cloud_db_index_utils_db_api_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../wm-cloud-db_index/utils/db_api/index */ "./src/packages/wm-cloud-db_index/utils/db_api/index.js");
// webLogin.js
// 获取应用实例



const app = getApp();
Page({
  data: {
    shareInfo: {},
    isShowBtn: false
  },
  onLoad(options) {
    this.initWebView(options);
  },
  async initWebView(options) {
    const isNeedLogin = options.isNeedLogin;
    let redirectUrl = decodeURIComponent(options.redirect);
    console.warn("options.redirect:", redirectUrl);
    if (isNeedLogin) {
      await new Promise(r => {
        wx.login({
          success: res => {
            console.warn("code:", res.code);
            Object(_wm_cloud_db_index_utils_db_api_index__WEBPACK_IMPORTED_MODULE_1__["reqDbLogin"])({
              code: res.code,
              redirect: redirectUrl,
              wid: _wm_cloud_db_index_utils_db_api_globalData__WEBPACK_IMPORTED_MODULE_0__["globalData"].wid
            }).then(res => {
              if (res.success) {
                _wm_cloud_db_index_utils_db_api_globalData__WEBPACK_IMPORTED_MODULE_0__["globalData"].loginToken = res.data.loginToken;
                // wx.setStorageSync('db_loginToken', res.data.loginToken)
                redirectUrl = res.data.redirectUrl;
                r(1);
              }
            }).catch(() => {
              r(1);
            });
          }
        });
      });
    }
    if (redirectUrl) {
      this.setData({
        path: redirectUrl
      });
    }
  },
  getMessage(e) {
    const {
      data
    } = e.detail;
    console.log(data, "data");
    if (data) {
      this.setData({
        share: data[data.length - 1]
      });
    }
  },
  onShareAppMessage: function (options) {
    //分享
    const {
      share
    } = this.data;
    console.warn(share.link, "share.link--------", JSON.stringify(options));
    // const shareurl = '/pages/webview/index?redirect=' + encodeURIComponent(share.link);
    if (share) {
      const shareurl = share.link;
      return {
        title: share.title,
        path: shareurl,
        imageUrl: share.imgUrl,
        success: function (res) {
          console.log(res, '成功');
          console.info(res + '成功');
          // wx.showToast({
          //   title: '分享成功',
          //   icon: 'none'
          // })
          // 转发成功
        },
        fail: function (res) {
          console.log(res + '失败');
          // 转发失败
        },
        complete: function (res) {
          // 不管成功失败都会执行
          console.log(res, '成功或失败');
        }
      };
    } else {
      return {
        title: "",
        path: "/packages/wm-cloud-db_index/db_index/index",
        imageUrl: "https://yun.duiba.com.cn/aurora/assets/bcce6f784bb575d94e9fec4e5ee98f2e7fa1cd85.png",
        success: function (res) {
          console.log(res, '成功');
          console.info(res + '成功');
          // wx.showToast({
          //   title: '分享成功',
          //   icon: 'none'
          // })
          // 转发成功
        },
        fail: function (res) {
          console.log(res + '失败');
          // 转发失败
        },
        complete: function (res) {
          // 不管成功失败都会执行
          console.log(res, '成功或失败');
        }
      };
    }
  }
});

/***/ })

/******/ }));