123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466 |
- <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="scImgMian()">
- <image v-if="!image_input" class="upload-img " src="/static/img/add.png"></image>
- <image v-if="image_input" class="upload-img " :src="image_input"></image>
- </view>
- </view>
-
- {{product.store_name}}
- <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/activity.js';
- import jinEdit from '@/components/jin-edit/jin-edit.vue';
- export default {
- components: {
- jinEdit
- },
- data() {
- return {
- lx: 0,
- AuthoriZation: '',
- id: 0,
- title: '',
- author: '',
- 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.AuthoriZation = 'Bearer ' + uni.getStorageSync('token')
- },
- onShow() {},
- onReachBottom() {},
- onReady() {},
- methods: {
- editOk(res) {
-
- 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.image_input[0]
- this.synopsis = data.news.synopsis
-
- this.content = data.news.content
- this.showwz = 0
- })
- },
- spxq(id) {
- goodsDetail({}, id).then(({
- data
- }) => {
- this.product = data.storeInfo
- console.log(data);
- })
- },
- scImgMian() {
- if (this.lx != 0) {
- return
- }
- let obj = this;
- upload({
- file: ''
- })
- .then(e => {
- console.log(e, 'e');
- obj.image_input = 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.image_input,
- synopsis: obj.synopsis,
- share_title: obj.title,
- share_synopsis: obj.synopsis,
- share_images: obj.image_input,
- content: obj.content,
- product_id: 0
- }).then(e => {
- if (type == 0) {
- uni.navigateTo({
- url: '/pages/user/creation?id=0'
- })
- } else {
- uni.navigateTo({
- url: '/pages/user/creation?id=2'
- })
- }
- })
- }, 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;
- .upload-left {
- font-weight: 400;
- font-size: 28rpx;
- }
- .upload-right {
- flex: 1;
- display: flex;
- align-items: center;
- justify-content: center;
- .upload-img {
- width: 200rpx;
- height: 200rpx;
- margin-top: 20rpx;
- }
- }
- }
- .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>
|