addressChoose.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <view class="container">
  3. <web-view src="https://uat.jzmall.lifejingzhi.com/address.html" @load="webviewOnLoad" @message="onMessage"></web-view>
  4. </view>
  5. </template>
  6. <script>
  7. var util = require('../../../utils/util.js');
  8. var api = require('../../../config/api.js');
  9. var app = getApp();
  10. export default {
  11. data() {
  12. return {};
  13. }
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */,
  17. onLoad: function (options) {},
  18. /**
  19. * 生命周期函数--监听页面初次渲染完成
  20. */
  21. onReady: function () {},
  22. /**
  23. * 生命周期函数--监听页面显示
  24. */
  25. onShow: function () {},
  26. /**
  27. * 生命周期函数--监听页面隐藏
  28. */
  29. onHide: function () {},
  30. /**
  31. * 生命周期函数--监听页面卸载
  32. */
  33. onUnload: function () {},
  34. /**
  35. * 页面相关事件处理函数--监听用户下拉动作
  36. */
  37. onPullDownRefresh: function () {},
  38. /**
  39. * 页面上拉触底事件的处理函数
  40. */
  41. onReachBottom: function () {},
  42. methods: {
  43. onMessage(options) {
  44. /**
  45. * 网页的消息发出顺序为 postMessage1、postMessage2、postMessage3
  46. * options.detail.data 的详细内容分别为:
  47. * [{ mes: "postMessage1" }, { mes: "postMessage2" }, { mes: "postMessage3" }]
  48. */
  49. console.log(options);
  50. console.log('onmessage:');
  51. console.log(options.detail.data);
  52. let data = options.detail.data;
  53. let address = data.length > 1 ? data[1].mes : data[0].mes;
  54. let msg = JSON.parse(address);
  55. console.log(msg);
  56. app.globalData.webAddress = msg;
  57. },
  58. webviewOnLoad() {
  59. console.log('webview 加载成功');
  60. }
  61. }
  62. };
  63. </script>
  64. <style></style>