productLink.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <view>
  3. <view class="form">
  4. <view class="form-item-title">产品标题</view>
  5. <view class="form-input-box">
  6. <input placeholder-class="form-input-placeholder" v-model="productTitle" placeholder="请输入产品标题"/>
  7. </view>
  8. <view class="form-item-title">产品链接</view>
  9. <view class="form-input-box ddflex">
  10. <input class="flex" v-model="productLink" placeholder-class="form-input-placeholder" placeholder="请填写或粘贴产品链接"/>
  11. <view class="clear-btn">清空</view>
  12. </view>
  13. <view class="next-btn" @click="submit">保存</view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. const app = getApp();
  19. const req = require("../../utils/request.js");
  20. export default {
  21. components: {},
  22. props: {},
  23. data() {
  24. return {
  25. systems: {},
  26. isTop:0,
  27. productTitle:'',
  28. productLink:''
  29. }
  30. },
  31. onLoad(options) {
  32. let pages = getCurrentPages();
  33. var prevPage = pages[pages.length - 2];
  34. if (prevPage) {
  35. this.productTitle = prevPage.$vm.productTitle
  36. this.productLink = prevPage.$vm.productLink
  37. }
  38. },
  39. onShow() {
  40. },
  41. methods: {
  42. submit(){
  43. if(!this.productTitle){
  44. return req.msg('请输入产品标题')
  45. }
  46. if(!this.productLink){
  47. return req.msg('请输入产品链接')
  48. }
  49. let pages = getCurrentPages();
  50. var prevPage = pages[pages.length - 2];
  51. if (prevPage) {
  52. prevPage.$vm.setData({
  53. productTitle:this.productTitle,
  54. productLink: this.productLink
  55. });
  56. }
  57. uni.navigateBack()
  58. }
  59. },
  60. mounted() {
  61. const systemInfo = uni.getSystemInfoSync();
  62. // px转换到rpx的比例
  63. let pxToRpxScale = 750 / systemInfo.windowWidth;
  64. let systems = {
  65. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  66. navigationHeight: 44 * pxToRpxScale // 导航栏的高度
  67. };
  68. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  69. this.systems = systems;
  70. },
  71. onPageScroll: function(e) {
  72. if (e.scrollTop > this.systems.barHeight) {
  73. this.isTop = 1;
  74. } else {
  75. this.isTop = 0;
  76. }
  77. }
  78. }
  79. </script>
  80. <style>
  81. @import "./productLink.css";
  82. </style>