uni-popup-share.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <view>
  3. <uni-popup-ori ref="showshare" type="bottom">
  4. <view class="uni-share">
  5. <text class="uni-share-title">分享到</text>
  6. <view class="uni-share-content">
  7. <view v-for="(item, index) in bottomData" :key="index" class="uni-share-content-box" @click="shareTo(item.name)">
  8. <view class="uni-share-content-image"><image :src="item.icon" class="content-image" mode="widthFix" /></view>
  9. <text class="uni-share-content-text">{{ item.text }}</text>
  10. </view>
  11. </view>
  12. <text class="uni-share-btn" @click="cancel()">取消分享</text>
  13. </view>
  14. </uni-popup-ori>
  15. <uni-popup-ori ref="showPast" type="center" class="popupPast">
  16. <view class="backPop">
  17. <view class="popPast">
  18. <view class="popTitle">口令已复制</view>
  19. <view class="popContent">
  20. <view>{{ describe }}</view>
  21. </view>
  22. <view class="popBtn" @click="goWhere(1)" v-if="popType == 'wx'">
  23. <!-- <image src="../../static/spend/wxin.png" mode="widthFix"></image> -->
  24. <view>去微信粘贴给好友</view>
  25. </view>
  26. <view class="popBtn" @click="goWhere(2)" v-if="popType == 'timeline'">
  27. <!-- <image src="../../static/spend/wechat.png" mode="widthFix"></image> -->
  28. <view>粘贴到朋友圈</view>
  29. </view>
  30. </view>
  31. <icon type="cancel" size="26" color="white" style="margin-top: 40rpx;" @click="cancelPo" />
  32. </view>
  33. </uni-popup-ori>
  34. </view>
  35. </template>
  36. <script>
  37. import uniPopupOri from '@/components/uni-popup/uni-popup-ori.vue';
  38. import { mapState, mapMutations } from 'vuex';
  39. import { getActionPage } from '@/utils/loginUtils.js';
  40. export default {
  41. name: 'SharePopup',
  42. components: {
  43. uniPopupOri
  44. },
  45. props: ['opt', 'type','option'],
  46. data() {
  47. return {
  48. describe: '',
  49. shareoption: '',
  50. bottomData: [
  51. {
  52. text: '微信',
  53. icon: '../../static/spend/wxin.png',
  54. name: 'wx'
  55. },
  56. {
  57. text: '朋友圈',
  58. icon: '../../static/spend/wechat.png',
  59. name: 'timeline'
  60. }
  61. ],
  62. popType: '',
  63. uid: ''
  64. };
  65. },
  66. computed: {
  67. ...mapState(['userInfo', 'baseURL'])
  68. },
  69. mounted() {},
  70. methods: {
  71. loadData() {
  72. try {
  73. let prePage = getActionPage();
  74. var path = prePage.route;
  75. this.uid = this.userInfo.uid;
  76. //获取object转化成
  77. var parm = '';
  78. var i = 0;
  79. var option = this.option; //其他页面传值
  80. console.log(option,'option')
  81. if(this.type == 4){
  82. parm = parm + '?' + 'promo_code=' + option;
  83. }else{
  84. for (let item in option) {
  85. //拼接参数
  86. if (i == 0) {
  87. parm = '?' + item + '=' + option[item];
  88. } else {
  89. parm = parm + '&' + item + '=' + option[item];
  90. }
  91. i++;
  92. }
  93. }
  94. if(this.type == 4){
  95. var url = 'pages/index/index' + parm;
  96. }else{
  97. var url = path + parm;
  98. }
  99. console.log(path,'path')
  100. console.log(parm,'parm')
  101. //用后台加密
  102. //第一个参数是判断是不是我们的链接
  103. //第二个参数是访问地址
  104. //第三个参数是,类型,type:0商品,type=1拼团,type=2邀请注册,type=3邀请好友参团,type=4邀请好友助力
  105. //第四个参数是share的id
  106. console.log(option,'option')
  107. if(this.type == 4){
  108. this.describe = this.baseURL + '@' + url + '@' + this.type + '@' + this.uid + '@复制这段话进入美美赚,自动打开页面';
  109. }else{
  110. this.describe = this.baseURL + '@' + url + '@' + this.type + '@' + this.uid + '@复制这段话进入美美赚,自动打开页面';
  111. }
  112. console.log(this.describe);
  113. let obj = this;
  114. // #ifndef H5
  115. uni.setClipboardData({
  116. data: this.describe,
  117. success: function () {
  118. uni.hideToast();
  119. }
  120. });
  121. // #endif
  122. } catch (e) {
  123. console.log(e);
  124. //TODO handle the exception
  125. }
  126. },
  127. goWhere(type) {
  128. this.$api.msg('复制成功');
  129. },
  130. cancelPo() {
  131. this.$nextTick(() => {
  132. this.$refs['showPast'].close();
  133. });
  134. },
  135. shareTo(name) {
  136. this.popType = name;
  137. this.$nextTick(() => {
  138. this.$refs.showPast.open();
  139. this.$refs['showshare'].close();
  140. });
  141. },
  142. cancel() {
  143. this.$nextTick(() => {
  144. this.$refs['showshare'].close();
  145. });
  146. },
  147. open() {
  148. this.$nextTick(() => {
  149. this.$refs['showshare'].open();
  150. });
  151. }
  152. }
  153. };
  154. </script>
  155. <style lang="scss" scoped>
  156. .backPop {
  157. padding: 0rpx 25rpx;
  158. display: flex;
  159. flex-direction: column;
  160. justify-content: center;
  161. align-items: center;
  162. }
  163. .popupPast {
  164. display: flex;
  165. flex-direction: column;
  166. justify-content: center;
  167. align-items: center;
  168. text-align: center;
  169. }
  170. .popPast {
  171. display: flex;
  172. flex-direction: column;
  173. justify-content: center;
  174. padding: 40rpx 30rpx;
  175. width: 90%;
  176. background-color: white;
  177. border-radius: 18rpx;
  178. align-items: center;
  179. .popTitle {
  180. color: #2f2f2f;
  181. font-size: 32rpx;
  182. font-weight: bold;
  183. margin-bottom: 40rpx;
  184. }
  185. .popContent {
  186. background-color: #f4f4f4;
  187. padding: 30rpx 24rpx;
  188. border-radius: 16rpx;
  189. view {
  190. font-size: 24rpx;
  191. color: #939393;
  192. }
  193. margin-bottom: 40rpx;
  194. }
  195. .popBtn {
  196. display: flex;
  197. align-items: center;
  198. padding: 20rpx 40rpx;
  199. background-color: #04be02;
  200. border-radius: 60rpx;
  201. image {
  202. width: 36rpx;
  203. }
  204. view {
  205. color: white;
  206. font-size: 36rpx;
  207. margin-left: 10rpx;
  208. }
  209. }
  210. }
  211. /* 底部分享 */
  212. .uni-share {
  213. /* #ifndef APP-NVUE */
  214. display: flex;
  215. flex-direction: column;
  216. /* #endif */
  217. background-color: #fff;
  218. }
  219. .uni-share-title {
  220. line-height: 60rpx;
  221. font-size: 24rpx;
  222. padding: 15rpx 0;
  223. text-align: center;
  224. }
  225. .uni-share-content {
  226. /* #ifndef APP-NVUE */
  227. display: flex;
  228. /* #endif */
  229. flex-direction: row;
  230. flex-wrap: wrap;
  231. justify-content: center;
  232. padding: 15px;
  233. }
  234. .uni-share-content-box {
  235. /* #ifndef APP-NVUE */
  236. display: flex;
  237. /* #endif */
  238. flex-direction: column;
  239. align-items: center;
  240. width: 200rpx;
  241. }
  242. .uni-share-content-image {
  243. /* #ifndef APP-NVUE */
  244. display: flex;
  245. /* #endif */
  246. flex-direction: row;
  247. justify-content: center;
  248. align-items: center;
  249. width: 60rpx;
  250. height: 60rpx;
  251. overflow: hidden;
  252. border-radius: 10rpx;
  253. }
  254. .content-image {
  255. width: 60rpx;
  256. height: 60rpx;
  257. }
  258. .uni-share-content-text {
  259. font-size: 26rpx;
  260. color: #333;
  261. padding-top: 5px;
  262. padding-bottom: 10px;
  263. }
  264. .uni-share-btn {
  265. height: 90rpx;
  266. line-height: 90rpx;
  267. font-size: 14px;
  268. border-top-color: #f5f5f5;
  269. border-top-width: 1px;
  270. border-top-style: solid;
  271. text-align: center;
  272. color: #666;
  273. }
  274. </style>