submit-link.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <tm-fullView>
  3. <view class="ma-32">
  4. <tm-coupon :hdata="calcBlogCoupon" color="blue" @click="blogDetailPoupShow=true"></tm-coupon>
  5. </view>
  6. <view class="pb-50">
  7. <tm-form @submit="fnOnSubmit">
  8. <tm-sheet :shadow="24" color="blue">
  9. <view class="text-size-s text-weight-b mb-24">友链信息提交</view>
  10. <tm-sheet :margin="[0,0]" :padding="[0,0]" :shadow="24" classname="overflow">
  11. <tm-input v-model="form.displayName" align="right" name="displayName" placeholder="请输入网站名称"
  12. required title="名称"></tm-input>
  13. <tm-input v-model="form.url" align="right" name="url" placeholder="请输入网站地址" required
  14. title="网址"></tm-input>
  15. <tm-input v-model="form.logo" align="right" name="logo" placeholder="请输入网站Logo" required
  16. title="Logo"></tm-input>
  17. <tm-input v-model="form.email" align="right" name="email" placeholder="请输入邮箱" required
  18. title="邮箱"></tm-input>
  19. <tm-input v-model="form.linkPageUrl" align="right" name="linkPageUrl" placeholder="请输入友链页面地址"
  20. title="友链页面"></tm-input>
  21. <view class="py-12 px-24 mx-12 round-3 border-b-1 grey text">
  22. <text class="text-grey text-size-xs px-10">
  23. <tm-helpTips :show="true" color="bg-gradient-blue-lighten-b" direction="bottom"
  24. label="展示本站链接的页面地址,用于校验是否添加本站友链" ment-direction="left" tip-direction="left">
  25. <tm-icons :fllowTheme="true" name="icon-question-circle"></tm-icons>
  26. </tm-helpTips>
  27. (贵站友情链接页面地址,即包含本站链接也页面)
  28. </text>
  29. </view>
  30. <tm-input v-model="form.rssUrl" align="right" name="rssUrl" placeholder="请输入RSS地址"
  31. title="RSS地址"></tm-input>
  32. <view class="py-12 px-24 mx-12 round-3 border-b-1 grey text">
  33. <text class="text-grey text-size-xs px-10">
  34. <tm-helpTips :show="true" color="bg-gradient-blue-lighten-b" direction="bottom"
  35. label="用于抓取文章" ment-direction="left" tip-direction="left">
  36. <tm-icons :fllowTheme="true" name="icon-question-circle"></tm-icons>
  37. </tm-helpTips>
  38. (用于抓取文章)
  39. </text>
  40. </view>
  41. <tm-input v-model="form.description" :border-bottom="false" :height="100" :maxlength="30"
  42. :vertical="true" bg-color="grey-lighten-5" input-type="textarea" name="description"
  43. placeholder="请输入网站描述,不超过30字符" required title="网站描述"></tm-input>
  44. <view class="px-24">
  45. <tm-button block navtie-type="form" theme="bg-gradient-blue-accent">提交数据</tm-button>
  46. <view class="py-32 text-size-s text-grey text-align-center">友链申请</view>
  47. </view>
  48. </tm-sheet>
  49. </tm-sheet>
  50. </tm-form>
  51. <tm-poup v-model="blogDetailPoupShow" :round="6" :width="640" height="auto" position="center">
  52. <view class="poup pa-36" scroll-y="auto">
  53. <view class="info flex">
  54. <view class="poup-logo pa-4 shadow-24">
  55. <image :src="blogDetail.logo" class="poup-logo_img" mode="aspectFill"></image>
  56. </view>
  57. <view class="pl-24 info-detail">
  58. <view class="poup-name text-size-lg text-weight-b">{{ blogDetail.name }}</view>
  59. <view class="poup-tag ml--10 text-size-n mt-10 text-grey">
  60. {{ blogDetail.description }}
  61. </view>
  62. </view>
  63. </view>
  64. <view class="poup-desc">
  65. <text>{{ calcBlogContent }}</text>
  66. </view>
  67. <!-- 博客预览图 -->
  68. <view class="mt-24">
  69. <tm-images :round="2" :src="caclSiteThumbnail(blogDetail.url)" :width="568"
  70. mode="aspectFill"></tm-images>
  71. </view>
  72. </view>
  73. <view class="poup-link flex flex-center mb-24">
  74. <tm-button theme="light-blue" size="n" @click="fnCopyLink(blogDetail.url)">复制友链交换信息</tm-button>
  75. <tm-button text theme="white" @click="blogDetailPoupShow = false">关闭</tm-button>
  76. </view>
  77. </tm-poup>
  78. </view>
  79. </tm-fullView>
  80. </template>
  81. <script>
  82. import tmFullView from "@/tm-vuetify/components/tm-fullView/tm-fullView.vue"
  83. import tmMenubars from "@/tm-vuetify/components/tm-menubars/tm-menubars.vue"
  84. import tmSheet from "@/tm-vuetify/components/tm-sheet/tm-sheet.vue"
  85. import tmForm from "@/tm-vuetify/components/tm-form/tm-form.vue"
  86. import tmActionSheet from "@/tm-vuetify/components/tm-actionSheet/tm-actionSheet.vue"
  87. import tmButton from "@/tm-vuetify/components/tm-button/tm-button.vue"
  88. import tmInput from "@/tm-vuetify/components/tm-input/tm-input.vue"
  89. import tmHelpTips from "@/tm-vuetify/components/tm-helpTips/tm-helpTips.vue"
  90. import tmIcons from "@/tm-vuetify/components/tm-icons/tm-icons.vue"
  91. import tmPoup from '@/tm-vuetify/components/tm-poup/tm-poup.vue'
  92. import tmImages from '@/tm-vuetify/components/tm-images/tm-images.vue'
  93. import tmTags from '@/tm-vuetify/components/tm-tags/tm-tags.vue'
  94. import tmCoupon from '@/tm-vuetify/components/tm-coupon/tm-coupon.vue'
  95. export default {
  96. components: {
  97. tmFullView,
  98. tmSheet,
  99. tmMenubars,
  100. tmForm,
  101. tmActionSheet,
  102. tmButton,
  103. tmInput,
  104. tmHelpTips,
  105. tmIcons,
  106. tmPoup,
  107. tmImages,
  108. tmTags,
  109. tmCoupon
  110. },
  111. data() {
  112. return {
  113. blogDetailPoupShow: false,
  114. blogDetail: this.$haloPluginsConfig.autoSubmitLink.blogDetail,
  115. form: {
  116. url: '', // 网址
  117. name: '', // 名称
  118. logo: '', // Logo
  119. linkPageUrl: '', // 友链页面
  120. team: '自助提交', // 分组
  121. description: '' // 描述
  122. }
  123. };
  124. },
  125. computed: {
  126. caclSiteThumbnail(val) {
  127. return val => {
  128. if (!val) return '';
  129. if (val.charAt(val.length - 1) != '/') {
  130. val = val + '/';
  131. }
  132. return 'https://image.thum.io/get/width/1000/crop/800/' + val;
  133. };
  134. },
  135. calcBlogContent() {
  136. return `
  137. 博客名称:${this.blogDetail.name}
  138. 博客地址:${this.blogDetail.url}
  139. 博客logo:${this.blogDetail.logo}
  140. 博客简介:${this.blogDetail.description}
  141. `
  142. },
  143. calcBlogCoupon() {
  144. return {
  145. img: this.blogDetail.logo,
  146. title: this.blogDetail.name,
  147. time: this.blogDetail.description,
  148. btnText: '友链详情'
  149. }
  150. }
  151. },
  152. onLoad() {
  153. this.fnSetPageTitle('友链申请');
  154. },
  155. methods: {
  156. fnOnSubmit(e) {
  157. if (e === false) {
  158. return uni.$tm.toast('请检查所有的必填项是否填写完整!');
  159. }
  160. if (this.form.url && !uni.$tm.test.url(this.form.url)) {
  161. return uni.$tm.toast('请输入正确的网站地址!');
  162. }
  163. if (this.form.logo && !uni.$tm.test.url(this.form.logo)) {
  164. return uni.$tm.toast('请输入正确的Logo地址!');
  165. }
  166. if (this.form.email && !uni.$tm.test.email(this.form.email)) {
  167. return uni.$tm.toast('请输入正确的邮箱地址!');
  168. }
  169. if (this.form.linkPageUrl && !uni.$tm.test.url(this.form.linkPageUrl)) {
  170. return uni.$tm.toast('请输入正确的友链页面地址!');
  171. }
  172. if (this.form.rssUrl && !uni.$tm.test.url(this.form.rssUrl)) {
  173. return uni.$tm.toast('请输入正确的RSS地址!');
  174. }
  175. this.fnHandle();
  176. },
  177. fnHandle() {
  178. uni.showLoading({
  179. title: '正在提交...'
  180. });
  181. this.$httpApi.v2.submitLink(this.form)
  182. .then(res => {
  183. if (res.code === 200) {
  184. uni.$tm.toast('友链提交成功!');
  185. setTimeout(() => {
  186. uni.navigateTo({
  187. url: '/pagesA/friend-links/friend-links',
  188. success() {
  189. let page = getCurrentPages().pop(); //跳转页面成功之后
  190. if (!page) return;
  191. page.onLoad(); //如果页面存在,则重新刷新页面
  192. }
  193. });
  194. }, 1000);
  195. } else {
  196. uni.$tm.toast('操作失败,请重试!');
  197. }
  198. })
  199. .catch(err => {
  200. uni.$tm.toast(err.msg);
  201. });
  202. },
  203. fnCopyLink() {
  204. uni.setClipboardData({
  205. data: this.calcBlogContent,
  206. showToast: false,
  207. success: () => {
  208. uni.showToast({
  209. icon: 'none',
  210. title: '复制成功!'
  211. });
  212. },
  213. fail: () => {
  214. uni.showToast({
  215. icon: 'none',
  216. title: '复制失败!'
  217. });
  218. }
  219. });
  220. }
  221. }
  222. }
  223. </script>
  224. <style lang="scss" scoped>
  225. .poup-logo {
  226. width: 140rpx;
  227. height: 140rpx;
  228. border-radius: 24rpx;
  229. overflow: hidden;
  230. &_img {
  231. width: 100%;
  232. height: 100%;
  233. }
  234. }
  235. .poup-desc {
  236. margin-top: -20rpx;
  237. font-size: 28rpx;
  238. line-height: 1.8;
  239. color: #555 !important;
  240. }
  241. .info-detail {
  242. width: 0;
  243. flex-grow: 1;
  244. justify-content: center;
  245. }
  246. pre {
  247. //方法一:保留空白符序列,但是正常地进行换行。
  248. white-space: pre-wrap;
  249. //方法二:添加横向滚动条
  250. overflow-x: auto;
  251. }
  252. </style>