123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381 |
- <template>
- <view class="virtual">
-
- <view class="box">
- <!-- <view class="box" v-for="(item,index) in goodsData" :key="index"> -->
- <!-- <view class="goods-item" v-for="i in item.goods" :key="i.mainId" @click="handleItem(i,item.name)"> -->
- <view class="goods-item" v-for="(item,index) in goodsData" :key="index" @click="handleItem(item)">
- <image class="icon" :src="item.cover&&item.cover.length&&item.cover[0]" mode=""></image>
- <view class="goods-info">
- <view class="goods-title" >
- <!-- {{i.name}} -->
- {{item.title}}
- </view>
- <view class="goods-desc">
- <!-- {{item.name}} -->
- {{item.title}}
- </view>
- </view>
- <view class="price">
- <!-- ¥{{i.calcPrice}} -->
- ¥{{Number(item.salePrice/100).toFixed(2)}}
- </view>
- </view>
- </view>
-
- <u-popup :show="show" round="32rpx" mode="bottom" @close="close" @open="open">
- <view class="content">
- <view class="popup-title">会员充值</view>
- <view class="goods-box">
- <image class="icon" :src="chooseInfo.mainImg" mode=""></image>
- <view class="goods-info">
- <view class="goods-title">
- {{chooseInfo.name}}
- <!-- {{chooseInfo.item_name}} -->
- </view>
- <view class="goods-desc">
- {{chooseInfo.catalogName}}
- </view>
- </view>
- <view class="price">
- <u-loading-icon v-if="loadingPrice" text="获取价格中"></u-loading-icon>
- <template v-else>
- ¥{{chooseInfo.price}}
- <!-- ¥{{chooseInfo.channel_price}} -->
- </template>
- </view>
- </view>
-
- <view class="notice">
- 暂不提供IOS用户进行充值业务
- </view>
-
- <u--form labelPosition="top" :model="form" ref="uForm" borderBottom labelWidth="180rpx" :labelStyle="{'color': '#222222',
- 'font-weight': 'bold','line-height':'60rpx','font-size': '28rpx'}">
- <u-form-item label="充值账号" prop="account" borderBottom ref="item1">
- <u--input v-model.trim="form.account" placeholder="请输入充值账号" border="none"></u--input>
- </u-form-item>
- </u--form>
- <view class="goods-describe">
-
- <rich-text :nodes="chooseInfo.goodsDescribe"></rich-text>
- </view>
- <button class="btn" type="default" :loading="loading" @click="handleBuy">确认</button>
- </view>
- </u-popup>
-
- <u-modal :show="iosShow" content='暂不提供IOS用户进行充值业务' @confirm="iosShow = false"></u-modal>
- </view>
- </template>
- <script>
- import {getVirtuallist,getVirtualInfo,getGoodsList} from '@/api/goods.js'
- import {SHOP_ID} from '@/utils/config.js'
- export default {
- data() {
- return {
- show: false,
- iosShow: false,
- goodsData:[],
- chooseInfo:null,
- loading:false,
- loadingPrice:false,
- form:{
- account:''
- },
-
- query:{
- regionCode:uni.getStorageSync('regionCode'),
- productType:['Recharge'],
- page:0,
- size:99
- }
- }
- },
- methods: {
- handleItem(item,catalogName) {
- // console.log(item,catalogName);
- // this.chooseInfo = JSON.parse(JSON.stringify(item) )
- // this.chooseInfo.catalogName = catalogName
- // this.show = true
- // this.getVirtualInfo(item.mainId)
- console.log(item,catalogName);
- this.chooseInfo = JSON.parse(JSON.stringify(item) )
- this.chooseInfo.catalogName = catalogName ||'无'
- let that = this
- uni.navigateTo({
- url:`/detail/virtualGoods/detail`,
- success: function(res) {
- // 通过eventChannel向被打开页面传送数据
- res.eventChannel.emit('data', that.chooseInfo)
- }
- })
- },
- open() {
- },
- close() {
- this.show = false
- },
- getVirtuallist(){
- uni.showLoading({
- title:'加载中'
- })
- getGoodsList(this.query).then(res=>{
- uni.hideLoading()
- if(res.state == 'Success'){
- this.goodsData = this.goodsData.concat(res.content.content)
- }
- })
- // getVirtuallist().then(res=>{
- // uni.hideLoading()
- // if(res.state == 'Success'){
- // this.goodsData = res.content.products
- // // this.goodsData = res.content
- // }
- // })
- },
- getVirtualInfo(commodityId){
- this.loadingPrice = true
- getVirtualInfo({commodityId}).then(res=>{
- this.loadingPrice = false
- if(res.state == 'Success'){
- this.chooseInfo.price = res.content.realPrice
- }
- })
- },
- // 创建订单
- handleBuy() {
- if (uni.getStorageSync('token')) {
- if(JSON.parse(uni.getStorageSync('userInfo')).setMealCode != 0&&JSON.parse(uni.getStorageSync('userInfo')).setMealCode){
- if(!this.form.account) return uni.showToast({
- title:'请输入充值账号',
- icon:'none'
- })
- let that = this
- uni.getSystemInfo({
- success(res){
- console.log(res.osName);
- if(res.osName == 'ios'){
- that.show = false
- that.iosShow = true
- }else{
- let info = {
- goodsId:that.chooseInfo.mainId,
- goodsName:that.chooseInfo.name,
- realPrice:that.chooseInfo.calcPrice,
- goodsImg:that.chooseInfo.mainImg,
- goodsDescribe:that.chooseInfo.catalogName,
- shopId:SHOP_ID,
- extend:JSON.stringify({account:that.form.account})
- }
- uni.navigateTo({
- url:`/detail/virtualGoods/pay`,
- success: function(res) {
- // 通过eventChannel向被打开页面传送数据
- res.eventChannel.emit('pay', info)
- }
- })
- }
- }
- })
- }else{
- uni.showModal({
- title:'此商品需要开通会员才能购买',
- cancelText:'下次再说',
- confirmText:'立即开通',
- success(res) {
- if(res.confirm){
- uni.navigateTo({
- url:'/my/memberCenter/index'
- })
- }
- }
- })
- }
-
-
- } else {
- uni.showModal({
- title:'请登录',
- confirmText:'去登录',
- success(res){
- console.log(res);
- if(res.confirm){
- uni.navigateTo({
- url:'/login/login/login?redirect=/detail/virtualGoods/index'
- })
- }
- }
- })
- }
-
- }
-
-
- },
- created() {
- this.getVirtuallist()
- },
- }
- </script>
- <style lang="scss" >
-
- .virtual {
- padding: 0 24rpx 80rpx;
- background: #fff;
- .title-box {
- display: flex;
- align-items: center;
- padding: 24rpx 0;
- .icon {
- width: 40rpx;
- height: 40rpx;
- border-radius: 50%;
- background: red;
- }
- .title {
- font-size: 32rpx;
- color: #222222;
- font-weight: bold;
- margin-left: 12rpx;
- }
- }
- .u-grid{
-
- .item{
- width: 218rpx;
- height: 218rpx;
- background: rgba(249,249,249,0.39);
- border: 2rpx solid #F0F0F0;
- border-radius: 16rpx;
- padding: 26rpx;
- box-sizing: border-box;
- margin-bottom: 24rpx;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- .item-title{
- font-size: 24rpx;
- color: #000000;
- font-weight: bold;
- margin-top: 14rpx;
- text-align: center;
- }
- .price{
- font-size: 40rpx;
- font-weight: bold;
- color: #A97D3C;
- margin-top: 16rpx;
- text-align: center;
- justify-self: flex-end;
- }
- }
- }
- .goods-item{
- display: flex;
- border-bottom: 2rpx solid #F0F0F0;
- padding: 28rpx 0;
- margin-top: 28rpx;
- .icon{
- width: 160rpx;
- height: 160rpx;
- border-radius: 16rpx;
- background: #F0F0F0;
- }
- .goods-info{
- display: flex;
- flex-direction: column;
- justify-content: center;
- flex: 1;
- margin-left: 20rpx;
- .goods-title{
- font-weight: 600;
- font-size: 32rpx;
- color: #222222;
- }
- .goods-desc{
- font-weight: 300;
- font-size: 24rpx;
- color: #AAAAAA;
- margin-top: 20rpx;
- }
- }
- .price{
- font-weight: 600;
- font-size: 36rpx;
- color: $uni-color-primary;
- align-self: center;
- }
- }
-
-
- .content{
- padding: 24rpx;
- .popup-title{
- font-size: 32rpx;
- font-weight: bold;
- color: #222222;
- }
- .goods-box{
- display: flex;
- margin-top: 28rpx;
- .icon{
- width: 160rpx;
- height: 160rpx;
- border-radius: 16rpx;
- background: #F0F0F0;
- }
- .goods-info{
- display: flex;
- flex-direction: column;
- justify-content: space-around;
- flex: 1;
- margin-left: 20rpx;
- .goods-title{
- color: #222222;
- font-weight: bold;
- font-size: 36rpx;
- }
- .goods-desc{
- font-size: 28rpx;
- color: #AAAAAA;
- }
- }
- .price{
- color: $uni-color-primary;
- font-size: 36rpx;
- font-weight: bold;
- align-self: center;
- }
- }
- .notice{
- font-size: 24rpx;
- color: #AAAAAA;
- padding: 26rpx 0;
- border-bottom: 2rpx solid #F0F0F0;
- }
- .goods-describe{
- color: #222222;
- font-size: 24rpx;
- max-height: 480rpx;
- padding-top: 28rpx;
- overflow: auto;
- }
- .btn{
- width: 688rpx;
- height: 80rpx;
- line-height: 80rpx;
- background: linear-gradient(283deg, #F8D48C 0%, #FBDDA6 100%);
- border-radius: 46rpx;
- margin-top: 54rpx;
- font-size: 28rpx;
- }
- }
-
- }
- </style>
|