商品信息

// 全局定義
var app = getApp();
var baseUrl = app.globalData.host;

var arr = [];
Page({
    
      

    /**
     * 頁面的初始數據
     */
    data: {
        interval2: 4000,
        duration: 2000,
        activeColor: "#fff",

        page_select: "page",
        jb: true,
        jc: true,
        showToast: '',

        t1m: '',
        t1b: '',
        tl: '',
        
        swiperImg: [],
        pt: '',
        titel: '',
        quan: '',
        fanLi: '',
        yuanJia: '',
        quanHou: '',
        link: '鏈接',//link or tkl
        links: '',

        fa: '',
        list_z: [],
        gq: '',
        sx: '',
        xjxx: '',
        tips: '',
    },

   

    /**
     * 生命週期函數--監聽頁面加載
     */
    onLoad: function (options) {
        //展示數據
        if(options!=null){
            var that = this;
            arr = options.data.split(",");

            //TH
            if(arr.length>=10){
                that.setData({
                    pt: arr[0],
                    titel: arr[1],
                    quan: arr[2],
                    fanLi: arr[3],
                    yuanJia: arr[4],
                    quanHou: arr[5],
                    links: arr[6],
                    icon: arr[7],

                    swiperImg: arr[8].split("|")
                });
                if(arr[0]==that.data.t1m || arr[0]==that.data.t1b){
                    that.setData({
                        link: that.data.tl
                    });
                }
            //BH
            }else{
                that.setData({
                    pt: arr[0],
                    titel: arr[1],
                    links: arr[4],
                    swiperImg: arr[6].split("|")
                });
                if(arr[0]==that.data.t1m || arr[0]==that.data.t1b){
                    that.setData({
                        link: that.data.tl
                    });
                }
            }
        }else{
            //請求數據
        }

        //zd
        var that = this;
        wx.request({
            url: baseUrl+'/stbh/xcx/zd',
            header: {},
            method: 'GET',
            dataType: 'json',
            responseType: 'text',
            success: function (res) {
                var zds = res.data.data;
                console.log(zds);
                that.setData({
                    t1b: zds.t1b,
                    t1m: zds.t1m,
                    tl: zds.tl,
                    gq: zds.gq,
                    sx: zds.sx,
                    list_z: zds.jb.split(","),
                    xjxx: zds.xjxx,
                    tips: zds.tips

                });
            },
        });

    },

    /**
     * 舉報
     */
    juBao: function () {
        this.setData({
            page_select: "page2",
            jb: false
        })
    },
    /**
     * 取消
     */
    quXiao: function () {
        this.setData({
            page_select: "page",
            jb: true
        });
    },

    /**
     * 教你
     */
    jiaoCheng:function(){
        this.setData({
            page_select: "page2",
            jc: false
        })
    },
    /**
     * 取消
     */
    quXiao_jc: function () {
        this.setData({
            page_select: "page",
            jc: true
        });
    },

    /**自定義提示框(顯示1.5秒後消失)*/
    showToast: function () {
        this.setData({
            showToast: true
        });
        setTimeout(() => {
            this.setData({
                showToast: false
            });
        },1000);
    },

    /**
     * 路子
     */
    link: function (e) {
        wx.setClipboardData({
            data: this.data.links,
            success: function (res) {
                wx.getClipboardData({
                    success: function (res) {
                        wx.showToast({
                            title: '複製成功'
                        })
                    }
                })
            }
        })
    },

    // 走
    th_lin: function (e) {
        wx.setClipboardData({
            data: e.currentTarget.dataset.tkl,
            success: function (res) {
                wx.getClipboardData({
                    success: function (res) {
                        wx.showToast({
                            title: '複製成功'
                        })
                    }
                })
            }
        })
    },

    /**
     * 生命週期函數--監聽頁面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命週期函數--監聽頁面顯示
     */
    onShow: function () {

    },

    /**
     * 生命週期函數--監聽頁面隱藏
     */
    onHide: function () {

    },

    /**
     * 生命週期函數--監聽頁面卸載
     */
    onUnload: function () {

    },

    /**
     * 頁面相關事件處理函數--監聽用戶下拉動作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 頁面上拉觸底事件的處理函數
     */
    onReachBottom: function () {

    },

    /**
     * 用戶點擊分享
     */
    onShareAppMessage: function (res) {
        
    }


      
 

})

 

<!-- 自定義提示框 -->
<view class="box1" wx:if="{{showToast}}">
  <view class="window">
    <view class="text2">
      {{toastText}}
    </view>
  </view>
</view>

<view class="{{page_select}}">
  <scroll-view scroll-y="true">
    <!-- 圖片 -->
    <view class="top">
      <swiper autoplay interval="{{interval2}}" duration="{{duration}}" indicator-dots indicator-active-color="{{activeColor}}">
        <block wx:for="{{swiperImg}}" wx:key="u">
            <swiper-item>
                <image src="{{item}}"></image>
            </swiper-item>  
        </block>
      </swiper>
    </view>

    <!-- 描述 -->
    <view class="info">
      <view class="title"><view class="pt">{{pt}}</view>\t{{titel}}</view>
      <view class="price">
        <view class="l1">{{quan}}</view><view class="l4">{{fanLi}}</view><view class="l2">{{yuanJia}}</view><view class="l3">{{quanHou}}</view>
      </view>
      <!-- left_btn and roght_btn -->
      <view class="sss">
        <view bindtap="juBao" class="right_btn">{{list_z[0]}}</view>
        <!-- <view bindtap="jiaoCheng" class="left_btn">{{list_z[1]}}</view> -->
      </view>
    </view>
  </scroll-view>


  <!-- 底部 -->
  <view class="bc">
    <view class="lj" bindtap="link" style='font-size:14px'>
      <view class="buttom_btn">
        <image style="width:2.5em;height:2em;" src="./../../img/copy_link.png"></image>
        <text style="padding-top:0.4em;">{{link}}</text>
      </view>
    </view>
    <button data-tkl="{{link}}" bindtap="th_lin" class="rivend" open-type='share' style='font-size:14px;'> 
       <view class="buttom_btn">
          <image style="width:2em;height:1.5em;margin-top:0.3em" src="./../../img/wx.png"></image><text style="margin-left:0.5em;margin-top:-0.2em">走返利</text>
       </view>
    </button>
    <!-- 底部提示-右邊 -->
    <view class="jb_btn" hidden="{{jb}}">
      <view class="jb_btn_">{{gq}}</view>
      <view class="jb_btn_">{{sx}}</view>
      <view class="jb_btn_">{{xjxx}}</view>
      <view class="quXiao" bindtap="quXiao">取消</view>
    </view>
    <!-- 底部提示-左邊 -->
    <view class="jb_btn" hidden="{{jc}}">
      <view class="jb_btn_">{{gq}}</view>
      <view class="jb_btn_">{{sx}}</view>
      <view class="jb_btn_">{{xjxx}}</view>
      <view class="quXiao" bindtap="quXiao_jc">取消</view>
    </view>
  </view>


</view>

 

/* 自定義提示框 */
.box1 {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  position: fixed;
  z-index: 999;
}
.window {
  width: 50%;
  padding: 20rpx;
  background: rgba(0, 0, 0, .5);
  border-radius: 20rpx;
}
.text2 {
  color: #fff;
  text-align: center;
}

.page{
  background-color: #fff;
}
.page2{
  background-color: rgb(192, 185, 185);
}

/* 圖片 */
.top{
  margin-top: 3px;
}
.top swiper{
  height: 240px;
}
swiper image{
 
  width: 750rpx;
}
/* 描述 */
.title{
  margin: 0.2em 0.2em;
  padding: 0.2em 0.2em;
  display: -webkit-box;
  overflow: hidden;/*超出一行文字自動隱藏 */
  text-overflow: ellipsis;/*文字隱藏後添加省略號*/
  word-wrap: break-word;
  white-space: normal !important;/*強制不換行 */
  -webkit-line-clamp: 2;/*多餘2行的部分以省略號顯示*/
  -webkit-box-orient: vertical;
}
.pt{
  color: white;
  background-color: #ff6633;
  display: inline;
  border-radius: 5px;
  font-size: 12px;
}

.price{
  margin-left: 0.2em;
}
.price .l3,.l2,.l4{
  margin-left: 7px;
}
.l1{
  color: #ff6633;
}
.l4{
  color: #ff6633;
}
.l2{
  color: gray;
  text-decoration:line-through;
}
.sss{
  font-size: 10px;
  margin-top: 4em;
}

.left_btn{
  position: fixed;
  color: blue;
  left: 0.8em;
  margin-top: -2em;
}
.right_btn{
  position: fixed;
  right: 0.8em;
  color: blue;
  margin-top: -2em;
}

/* 列表詳情 */
.info{
  width: 750rpx;
  height: 100%;
}
.li {
  margin: 0.4em 0.8em;
  padding: 0.2em 0.2em;
  display: flex;
  justify-content: space-around;
  width: 92%;
  height: 225rpx;
  font-size:14px;
  margin-bottom: 3.5em;
}

.bg-gray{
  background-color: rgb(255, 255, 255)!important;
  border-bottom: 1rpx solid  #fff!important;
}
.img{
  width: 100px;
  height: 110px;
  
}
.price1{
  margin-top: 10px;
}
.price{
  display: inline;
}
.price view{
  display: inline;
}
.price .l3,.l2{
  margin-left: 7px;
}
.l1{
  color: #ff6633;
}
.l2{
  color: gray;
}
::-webkit-scrollbar{/*隱藏滾動條*/
width: 0;
height: 0;
color: transparent;
}
.pt{
  color: white;
  background-color: #ff6633;
  display: inline;
  border-radius: 5px;
  font-size: 12px;
}
/* 底部 */
.lj{
  position: fixed;
  bottom: 2px;
  color: white;
  background-color: #ff6633;
  width: 50%;
  margin-right: 50%;
  height: 2.2em;
  border-radius: 15rpx;
  font-weight: bold;
}

.rivend{
  position: fixed;
  bottom: 2px;
  color: white;
  background-color: #00EE76;
  width: 50%;
  margin-left: 50%;
  height: 2.2em;
  border-radius: 15rpx;
  font-weight: bold;
}
.jb_btn{
  position: fixed;
  bottom: 0.5em;
  color: blue;
  background-color: white;
  width: 84%;
  text-align: center;
  margin-left: 8%;
  line-height: 1em;
  border-radius: 15rpx;
  z-index: 999;
}
.jb_btn_{
  margin-top: 1em;
  border-bottom:1px solid rgb(167, 163, 163);
  height: 2em;
}
.quXiao{
  margin-top: 1em;
  border-bottom:1px solid grey;
  height: 2em;
}
.buttom_btn{
  display:flex;
  justify-content: center;
  
}

  "pages": [

    "pages/sy/sy",

    "pages/wd/wd",

    "to2pages/productInfo/productInfo"

  ],

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章