123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507 |
- <template>
- <view class="content">
- <view class="main">
- <view class="box-1">
- <view class="box-left">标题:</view>
- <input type="text" :disabled="lx != 0" v-model="title" placeholder-class="placeholder"
- class="list-input" placeholder="请填写文章标题" />
- </view>
- <view class="box-1">
- <view class="box-left">作者:</view>
- <input type="text" :disabled="lx != 0" v-model="author" placeholder-class="placeholder"
- class="list-input" placeholder="请填写文章作者" />
- </view>
- <view class="box-1">
- <view class="box-left">文章简介:</view>
- <input type="text" :disabled="lx != 0" v-model="synopsis" placeholder-class="placeholder"
- class="list-input" placeholder="请填写文章简介" />
- </view>
- <view class="upload-box">
- <view class="upload-left">文章头图</view>
- <view class="upload-right " @click.stop="banner_img_up()">
- <view class="upload-imgbox">
-
- <image v-if="!banner_img" class="upload-img " src="/static/img/add.png"></image>
- <image v-if="banner_img" class="upload-img " :src="banner_img"></image>
- </view>
- </view>
- </view>
- <view class="upload-box">
- <view class="upload-left">分享素材</view>
- <view class="flex">
- <view class="upload-right flex-start">
- <view class="position-relative upload-imgbox" v-for="(src,ind) in image_input">
- <image :src="src" class="upload-img "></image>
- <view class="delText" @click="image_input.splice(ind,1)">
- 删除
- </view>
- </view>
- <view class="upload-imgbox">
- <image @click.stop="scImgMian()" class="upload-img " src="/static/img/add.png"></image>
- </view>
- </view>
- </view>
- </view>
- <!-- <view class="box-1">
- <view class="box-left">
- 关联商品 :
- </view>
- <view class="list-input" v-if="!product" @click="open()">
- 请选择关联商品
- </view>
- <view class="list-input clamp" v-else @click="open()">
- {{product.store_name}}
- </view>
- </view> -->
- <view class="bjq" v-if="showwz == 0&&lx ==0">
- <jinEdit ref="set" placeholder="请输入文章内容" @editOk="editOk" uploadFileUrl="/api/upload/image"
- :header="{'Authori-zation': AuthoriZation}" :showImgSize="true" :html="content" height="50vh">
- </jinEdit>
- </view>
- <view class="bjq" v-if="lx !=0">
- <view v-html="content"></view>
- </view>
- </view>
- <view @click.stop="submit('1')" v-if="lx == 0" class="address-box submit-box"><text
- class="submit-btn">提交文章</text></view>
- <view @click.stop="submit('0')" v-if="lx == 0" class="address-box submit-box"><text
- class="submit-btn gren">保存草稿</text></view>
- <!-- <uni-popup ref="choose" type="bottom">
- <view class="choose-main">
- <view class="choose-top flex">
- <view class="choose-font" @click="close()">
- 取消
- </view>
- </view>
- <view class="top-box">
- <view class="top">
- <view class="top-icon">
- <image src="../../static/icon/icon.png" mode=""></image>
- </view>
- <view class="top-main"><input type="text" v-model="keyworld" placeholder="请输入商品名称"></view>
- </view>
- <view class="top-font" @click="clickSearch()">
- 搜索
- </view>
- </view>
- <scroll-view scroll-y="true" style="height: 600rpx;" @scrolltolower="getProduct()">
- <view class="choose-item flex" v-for="(item,index) in productlist" @click="xuanzhe(item)">
- <view class="choose-image">
- <image :src="item.image" mode=""></image>
- </view>
- <view class="choose-rigt">
- <view class="choose-name">
- {{item.store_name}}
- </view>
- <view class="choose-price">
- {{item.price}}
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- </uni-popup> -->
- </view>
- </template>
- <script>
- import {
- upload
- } from '@/api/order.js';
- // import {
- // getProducts,
- // goodsDetail
- // } from '@/api/product.js'
- import {
- my_detail,
- add_article
- } from '@/api/user.js';
- import jinEdit from '@/components/jin-edit/jin-edit.vue';
- export default {
- components: {
- jinEdit
- },
- data() {
- return {
- lx: 0,
- AuthoriZation: '',
- id: 0,
- title: '', //文章标题
- author: '', //文章作者
- banner_img: '', //头图
- image_input: [], //文章图片
- content: '', //文章内容
- synopsis: '', //文章简介
- product: '', //关联商品
- productlist: [], //商品列表
- page: 1,
- limit: 10,
- loadType: 'more',
- keyworld: '',
- showwz: 0,
- };
- },
- onLoad(opt) {
- if (opt.id) {
- this.showwz = 1;
- this.id = opt.id;
- this.loadData();
- }
- if (opt.type) {
- this.lx = opt.type
- }
- console.log(this.product);
- // this.getProduct();
- this.AuthoriZation = 'Bearer ' + uni.getStorageSync('token')
- },
- onShow() {},
- onReachBottom() {},
- onReady() {},
- methods: {
- editOk(res) {
- // 保存富文本转出的html
- this.content = res.html
- console.log(this.content);
- },
- // getProduct() {
- // const obj = this
- // if (obj.loadType == 'noMore' || obj.loadType == 'loading') {
- // return
- // }
- // obj.loadType = 'loading'
- // getProducts({
- // page: obj.page,
- // limit: obj.limit,
- // keyword: obj.keyworld
- // }).then(({
- // data
- // }) => {
- // obj.productlist = obj.productlist.concat(data);
- // obj.page++
- // if (data.length == obj.limit) {
- // obj.loadType = 'more'
- // } else {
- // obj.loadType = 'noMore'
- // }
- // })
- // },
- loadData() {
- my_detail({}, this.id).then(({
- data
- }) => {
- this.title = data.news.title
- this.author = data.news.author
- this.image_input =data.news.share_images;
- this.banner_img = data.news.image_input[0];
- this.synopsis = data.news.synopsis
- // this.spxq(data.news.product_id)
- this.content = data.news.content
- this.showwz = 0
- })
- },
- // spxq(id) {
- // goodsDetail({}, id).then(({
- // data
- // }) => {
- // this.product = data.storeInfo
- // console.log(data);
- // })
- // },
- banner_img_up() {
- if (this.lx != 0) {
- return
- }
- let obj = this;
- upload({
- file: ''
- })
- .then(e => {
- console.log(e, 'e');
- obj.banner_img = e[0].url;
- })
- .catch(e => {});
- },
- scImgMian() {
- if (this.lx != 0) {
- return
- }
- let obj = this;
- upload({
- file: ''
- })
- .then(e => {
- console.log(e, 'e');
- obj.image_input.push(e[0].url);
- })
- .catch(e => {});
- },
- // clickSearch() {
- // this.page = 1;
- // this.limit = 10;
- // this.loadType = 'more'
- // this.getProduct();
- // },
- // open() {
- // if (this.lx != 0) {
- // return
- // }
- // this.$refs.choose.open()
- // },
- // close() {
- // this.$refs.choose.close()
- // },
- xuanzhe(opt) {
- this.product = opt;
- console.log(this.product, '123456');
- this.$refs.choose.close();
- },
- submit(type) {
- const obj = this
- this.$refs.set.release(true)
- setTimeout(() => {
- if (!obj.title) {
- return this.$api.msg('请输入文章标题')
- }
- if (!obj.author) {
- return this.$api.msg('请输入文章作者')
- }
- if (!obj.image_input) {
- return this.$api.msg('请输入文章头图')
- }
- if (!obj.synopsis) {
- return this.$api.msg('请输入文章简介')
- }
- if (!obj.content) {
- return this.$api.msg('请输入文章内容')
- }
- add_article({
- type: type,
- id: obj.id,
- title: obj.title,
- author: obj.author,
- image_input: obj.banner_img,
- synopsis: obj.synopsis,
- share_title: obj.title,
- share_synopsis: obj.synopsis,
- share_images: obj.image_input.join(','),
- content: obj.content,
- product_id: 0
- }).then(e => {
- uni.navigateTo({
- url: '/pages/user/release?id=0'
- })
- })
- }, 10)
- }
- }
- };
- </script>
- <style lang="scss">
- page,
- .content {
- min-height: 100%;
- height: auto;
- }
- .box-1 {
- background: #ffffff;
- display: flex;
- justify-content: space-between;
- align-items: center;
- width: 100%;
- padding: 20rpx;
- .box-left {
- width: 25%;
- text-align: left;
- color: #000000;
- }
- .list-input {
- width: 75%;
- font-size: 28rpx;
- color: #959595;
- text-align: right;
- padding-right: 24rpx;
- }
- }
- .upload-box {
- width: 100%;
- background: #ffffff;
- border-radius: 27rpx;
- display: flex;
- flex-direction: column;
- padding: 30rpx 40rpx;
- margin: 20rpx auto 30rpx;
- padding-right: 0;
- .upload-left {
- font-weight: 400;
- font-size: 28rpx;
- }
- .upload-right {
- flex-wrap: wrap;
- .delText {
- background-color: rgba(0, 0, 0, 0.6);
- color: #FFF;
- text-align: center;
- position: absolute;
- bottom: 0;
- width: 100%;
- }
- .upload-imgbox {
- margin-top: 20rpx;
- margin-right: 20rpx;
- .upload-img {
- width: 200rpx;
- height: 200rpx;
- }
- }
- }
- }
- .main {
- padding: 20rpx;
- }
- .bjq {
- margin-top: 20rpx;
- background: #ffffff;
- padding: 20rpx;
- }
- .address-box {
- padding: 15rpx 40rpx;
- margin-bottom: 10px;
- }
- .submit-box {
- bottom: 0;
- left: 0;
- width: 750rpx;
- }
- .submit-btn {
- margin-top: 10px;
- display: inline-block;
- width: 670rpx;
- height: 96rpx;
- line-height: 96rpx;
- text-align: center;
- background-color: #000000;
- opacity: 1;
- box-shadow: 0rpx 8rpx 12rpx rgba(0, 0, 0, 0.16);
- border-radius: 56rpx;
- font-size: 39rpx;
- font-weight: bold;
- color: rgba(255, 255, 255, 1);
- }
- .gren {
- background: #ffffff;
- color: #000000;
- border: 1px solid #000000;
- }
- .choose-main {
- background: #ffffff;
- }
- .choose-top {
- padding: 20rpx 40rpx 20rpx;
- font-size: 32rpx;
- justify-content: flex-end;
- .choose-font {
- color: #d4c7c2;
- }
- }
- .choose-item {
- padding: 40rpx 20rpx;
- justify-content: flex-start;
- .choose-image {
- width: 100rpx;
- height: 100rpx;
- image {
- width: 100%;
- height: 100%
- }
- }
- .choose-rigt {
- height: 100rpx;
- margin-left: 20rpx;
- padding: 10rpx 0;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- .choose-name {
- font-size: $font-base;
- color: $font-color-dark;
- font-weight: bold;
- }
- .choose-price {
- font-size: 32rpx;
- font-family: PingFang SC;
- font-weight: 800;
- color: #ff4c4c;
- line-height: 1;
- }
- }
- }
- .top-box {
- display: flex;
- justify-content: center;
- align-items: center;
- }
- .top-font {
- font-size: 32rpx;
- color: #000000;
- margin-left: 20rpx;
- }
- .top {
- width: 550rpx;
- height: 58rpx;
- background: #ededed;
- border-radius: 29rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- .top-icon {
- width: 32rpx;
- height: 32rpx;
- image {
- width: 100%;
- height: 100%;
- }
- }
- .top-main {
- margin-left: 20rpx;
- font-size: 28rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #cbcbcb;
- }
- }
- </style>
|